Search
⌘K

Leetcode 1963. Minimum Number of Swaps to Make the String Balanced

Given an even-length string with equal numbers of '[' and ']', compute the minimum number of swaps of any two characters needed to transform it into a balanced bracket sequence. The core challenge is to greedily track running balance and fix negative imbalances (consecutive excess ']') with the fewest pairwise swaps.


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.