Problems > Balanced Brackets > Editorial

Balanced Brackets — Solution & Editorial

Back to the Problem

Track the nesting depth; it must never go negative and must end at zero.

Complexity: O(|S|)