Longest run of ones with k flips
bits is a list of 0s and 1s. Write longest_ones(bits, k) that returns the longest
run of consecutive items you could make all 1 by flipping at most k zeros.
longest_ones([1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0], 2) -> 6
longest_ones([0, 0, 0], 0) -> 0
longest_ones([0, 0], 5) -> 2
The point is to practise a variable window whose validity rule is "at most k zeros inside".
def longest_ones(bits, k):
...