Solution for Valid Parentheses