Leetcode 3191. Minimum Operations to Make Binary Array Elements Equal to One I
Given a binary array, find the minimum number of operations that flip any 3 consecutive bits so that all elements become 1, or return -1 if impossible. The core challenge is choosing an optimal sequence of overlapping length-3 flips — solvable by treating flips mod 2 (a linear system over GF(2)) or by a greedy sliding-window/difference approach to track active flips in O(n).
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.