A row of LEDs is described by bits, where 1 is on and 0 is off. You may flip individual LEDs on. Return the minimum number of flips needed so that some block of exactly k consecutive LEDs is entirely on.
Examples
Input: bits = [1, 0, 0, 1, 1, 0, 1], k = 3
Output: 1
Explanation: the block [0, 1, 1] at indices 2..4 needs only one flip.
Input: bits = [0, 0, 0], k = 2
Output: 2
Constraints
1 <= k <= len(bits) <= 10**5bits[i]is0or1- Target complexity: O(n) time; recounting each window from scratch is too slow for the largest tests.
Goals
- Count zeros inside a fixed window incrementally
- Track the minimum across windows