Longest ones after flips
Your task
Given a binary array a (values 0 or 1) and an integer k, return the length of the longest contiguous subarray containing only 1s after flipping at most k zeros to ones. k is non-negative; the array may be all zeros.
Examples
longest_ones_k_flips(a: list[int], k: int) -> intExample 1
Input
longest_ones_k_flips([1, 1, 0, 0, 1, 1, 1, 0, 1], 2)Output
7