Trains the technique from
LeetCode 1888Minimum Number of Flips to Make the Binary String AlternatingThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A calibration band is a closed loop of printed cells wrapped around a drum. Each cell carries either '0' or '1'. The reader makes one full pass over the loop, starting at the cell sitting under the head mark, and writes what it saw as the string band.
Before the drum is certified you may use these two adjustments, in any order and as often as you like:
'0' into '1' or its '1' into '0'. Each repaint costs one unit.The drum is certified once no two neighbouring cells of the pass carry the same character.
Return the smallest total repaint cost that certifies the drum.
Example 1
Advancing the drum once makes the pass `1000111`. Repainting its third and sixth cells leaves `1010101`, where no two neighbours carry the same character, for a cost of 2.
Example 2
Advancing the drum twice makes the pass `1010101`, whose neighbours already differ everywhere, so nothing is repainted.
Example 3
Repainting the first and third cells leaves the pass `0101`, where no two neighbours carry the same character, for a cost of 2.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def min_repaint_cost(band: str) -> int:public int minRepaintCost(String band)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.