← ALL NOTES
String

1021. Remove Outermost Parentheses

The outermost parentheses of a primitive are exactly the two that touch depth zero: the ( that lifts the nesting level from 0 to 1, and the ) that drops it back to 0. Every other character is strictly inside something, so it survives. That turns a statement about decomposition into a single running counter.

Loading…