Given a string containing just the characters ‘(‘ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.
Example
No.1
Input: “(()”
Output: 2
Explanation: The longest valid parentheses substring is “()”
No.2
Input: “)()())”
Output: 4
Explanation: The longest valid parentheses substring is “()()”
Code
1 | public int longestValidParentheses(String s) { |