Top Hat Interview Question

The Valid Parenthesis Question from Leetcode