bits of zeros and ones.
In one operation you pick a position i and flip every element from i to the end of the array: zeros become ones and ones become zeros.
Return the minimum number of operations after which the array contains only ones.bits=[1, 1, 0, 0, 1] → 2
Flip the tail from position 2: [1, 1, 1, 1, 0]. Then the tail from position 4: all ones. 2 flips in total.
bits=[0, 0, 0] → 1
A single flip of the whole array from position 0 is enough.
bits=[1, 0, 1, 0] → 3
bits=[1, 1, 0, 0, 1]
2
Run checks the first 3 tests in your browser. Submit checks all 71 tests on the server, hidden ones included.