bits of 0 and 1 characters. The signal is supposed to be a single step: only zeros first, then only ones (either part may be empty).
One fix flips any single character to the other value. Return the smallest number of fixes that turns the string into such a step.bits='010110' → 2
Two fixes are enough: change the 1 at index 1 to 0 and the 0 at index 5 to 1, giving 000111.
bits='1100' → 2
Either clear both ones (0000) or set both zeros (1111); either way it takes two fixes.
bits='0011' → 0
The string is already in order, so nothing needs fixing.
bits contains only 0 and 1bits='010110'
2
Run checks the first 3 tests in your browser. Submit checks all 146 tests on the server, hidden ones included.