Hitachi Vantara interview question

Check for Balanced Parentheses.