Domanda di colloquio di Bottomline

How to solve the matching parentheses Leetcode problem