845. Max Consecutive 1's
0
Medium
Cheems has been given a binary array of size N. He wants to maximize the length of the longest consecutive sequence of 1's. He possesses a Magic stick with a power of 'K', which allows him to flip 0's to 1's a maximum of K times. Your task is to determine the length of the longest consecutive sequence of 1's that can be achieved using the magic stick.
Input Format
The first line contains two space-separated integers N and K. The second line contains a binary array of length N.
Output Format
An integer representing the length of the longest consecutive sequence of 1's.
Example
Input
11 2
1 1 1 0 0 0 1 1 1 1 0
Output
6
Constraints
1 <= N <= 10000
Loading...
View Submissions
Console