Solved valid parentheses problem.