In one operation, choose exactly three consecutive entries of the binary array nums and flip all three bits. Return the fewest operations needed to make every entry equal to 1, or -1 if this is impossible.
Example 1:
Input: nums = [0,0,0]
Output: 1Explanation: Flip the only group of three entries to change [0,0,0] into [1,1,1].
Example 2:
Input: nums = [1,1,1]
Output: 0Explanation: All entries are already 1, so no operation is needed.
Example 3:
Input: nums = [1,0,0,0]
Output: 1Explanation: Flip the last three entries once, obtaining [1,1,1,1].
Constraints:
3 <= nums.length <= 1000000 <= nums[i] <= 1