Braze interview question

leetcode style question related to parenthesis