Zillow interview question

A variant of Valid parentheses Leetcode medium