Earnix interview question

Leet code - brackets question