Qualcomm interview question

balanced parentheses