PropertyGuru Group Interview Question

The validate parenthesis based on stack DSA question. Optimise a existing API.