Loading…
Loading…
Given a binary array nums and an integer k, return the longest subarray of 1s possible if you can flip at most k zeroes to 1s.
Input: 1 1 1 0 0 0 1 1 1 1 0, k = 2
Output: 6
Sliding window that tracks the count of zeroes inside it. Expand right freely; when the zero count exceeds k, shrink from the left until it's back within budget. Track the max window size seen.
Line 1: the array, space-separated Line 2: k
Input (stdin)
Output
Input (stdin)
Output
Sign in to track solved problems and earn XP.