3 ms·
It's easier with a stack and it avoids common mistakes from other algorithms. Also easier to generalize to follow up problems like multiple characters. Push on
by user5994461 8y ago
It's easier with a stack and it avoids common mistakes from other algorithms. Also easier to generalize to follow up problems like multiple characters.
Push on opening parenthesis. Pop on closing parenthesis. Trivial.