Warner Bros. Discovery interview question

Q: matching brackets , two sum