Re:A Brutal Look at Balanced Parentheses, Computing Machines...
by kerkeslager on Saturday February 23, 2019 @08:01AM
(#19233164)
The solution I posted doesn't use a stack, or any other data structures for that matter.
[ Parent
| on HN ]
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.