PwC interview question

an leetcode question valid parenthesis