Netenrich Inc. interview question

Braceket matching stack based question