Amazon interview question

Leetcode 20. Valid Parentheses And then a variation.