Problem 1541 · Medium

Minimum Insertions to Balance a Parentheses String

Each open bracket needs two close brackets, so track open brackets and insert whatever is missing as you scan.

Open the interactive visualisation