Tripadvisor interview question

Balanced brackets (without stack / time complexity vs space complexity / improve time complexity)