Chatham Financial interview question

Parenthesis validation