Brex interview question

LC Easy, Valid Parentheses problem