Search
⌘K

Leetcode 2712. Minimum Cost to Make All Characters Equal

Given a binary string s (n ≤ 1e5), you may flip any prefix ending at i (cost i+1) or any suffix starting at i (cost n−i); compute the minimum total cost to make all characters identical. The challenge is to choose prefix/suffix flips—which toggle runs and can cancel each other—optimally to remove transitions and reach all 0s or all 1s.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.