stack压下标
class Solution {
public:
int longestValidParentheses(string s) {
int N = s.length();
stack<int> S;
for(int i=0;i<N;i++){
if(S.empty()) S.push(i);
else{
if(s[i] == ')' && s[S.top()] == '(') S.pop();
else S.push(i);
}
}
int ans = 0;
int R = N;
while(!S.empty()){
ans = max(ans,R-S.top()-1);
R = S.top();
S.pop();
}
ans = max(ans,R-0);
return ans;
}
};