Two solutions for longest valid parentheses