Globant Interview Question

Q: Balance the brackets (coding problem)