IBM Interview Question

DSA question about balanced paranthesis