HSBC interview question

Valid paranthesis question on leetcode