Stack-based parenthesis matching
Which data structure validates balanced brackets in a single pass, and at what cost?
Show hints (2)+
- You must match the most recent unmatched opener first.
- Last-in, first-out.
Answer
Reveal answer →Final answer
A stack — $O(n)$
Want the full step-by-step worked solution? It's part of Premium — along with a worked solution for every question in the bank.
Asked at: Jane Street, IMC