Re:A Brutal Look at Balanced Parentheses, Computing Machines...
by user5994461 on Saturday February 23, 2019 @11:02AM
(#19233876)
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.
Push on opening parenthesis. Pop on closing parenthesis. Trivial.