longest valid parentheses solution