solution to Valid Parentheses