code Longest valid parentheses with stack implementation