Problem 2712 · Medium

Minimum Cost to Make All Characters Equal

Each boundary where neighbours differ must be crossed once, and the cheaper of its prefix or suffix flip pays for it.

Open the interactive visualisation