Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.
For “(()”, the longest valid parentheses substring is “()”, which has length = 2.
Another example is “)()())”, where the longest valid parentheses substring is “()()”, which has length = 4.
Subscribe to see which companies asked this question
package cc.stack.application;
import java.util.Stack;
/*
* 字符串遍历,遇"("入栈,遇")"且栈顶是"(",ok一次
*/
class Solution {
public int longestValidParentheses(Strin