Leetcode 995. Minimum Number of K Consecutive Bit Flips
Given a binary array and an integer k, compute the minimum number of length-k subarray flips needed to make all elements 1 (or return -1 if impossible). The core challenge is handling overlapping flips efficiently — use a greedy left-to-right approach that tracks the current parity of applied flips (via a difference array or sliding window) to decide when to flip.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.