So I’ve solved Valid Parentheses on Leetcode a few times now for space repetition. I totally get the stack solution now, but what I don’t understand is how to come upon the intuition that helps you realize you need a stack data structure. First couple attempts I tried a weird two pointer approach, which I totally understand why it doesn’t work. What are parts of the problem that clue you into the fact you need to use a stack?
You need to sign in to view this answers