Pregunta de entrevista de Bottomline

How to solve the matching parentheses Leetcode problem