Hitachi Vantara Interview Question

Check for Balanced Parentheses.