面试官要求时间复杂度为O(n),空间复杂度为O(1) public class Solution { public int longestValidParentheses (String s) { int left =0,right =0, maxLen = 0; for(int i=0;i<s.length()-1;i++){ if(s.charAt(i)=='(') left++; else right++; if(left==right) maxLen = Math.max(maxLen,2*right); else if(right>left) left =right = ...