Globant interview question

Q: Balance the brackets (coding problem)