双指针,正反(一个合法断里面的前缀or后缀) class Solution { public: int longestValidParentheses(string s) { int l = 0, r = 0, ans = 0; for(int i = 0; i < s.size(); i ++) { if(s[i] == '(') l ++; if(s[i] == ')') r ++; if(l == r) ans = max(ans, l + r); ...