Problem Brief
Minimum Flips to Alternate Binary String (With K Flip Window)
NEW GRADOA
See Google online assessment and hiring insights
You are given a binary string s. In one operation, you can flip a subarray of length exactly k (flip all bits in that subarray). Return the minimum number of such operations needed to make the string alternating (i.e., no two adjacent bits are the same). If it's not possible, return -1.
1Example 1
Input
s = "00010111", k = 3
Output
2
Explanation
^~^