Given a string containing only ( and ), return the length of the longest valid (well-formed) parentheses substring.
(
)
s = "(()"
2
Why
The substring "()" is valid.
s = ")()())"
4
0 <= s.length <= 3 * 10^4 `s` contains only `(` and `)`.
Topics
Implement longestValidParentheses in the editor and return the answer — printing it is never graded.
longestValidParentheses
Problem 101 of 1146 in the arena