Amazon Interview Question

Matching parentheses leetcode problem (same as found online)