Interview problems never say "use a stack". You have to recognise the shape of the problem. The good news is that stack problems give themselves away with a handful of signals.
[ and ] in an encoded string — anything where the latest opening must close first. (Valid Parentheses, Decode String)Members only · free account
The rest of this lesson, with 4 more sections, 2 drawings, a dry-run simulator and code in JavaScript, Python, Java and C++, opens with a free account.
Not ready yet? The Arrays course is free to read, no account needed.
In the rest of this lesson