TSS Consultancy Interview Question

Code based on parentheses matching.