Amazon interview question

valid brackets on leetcode and we dove a bit deeper