
解题思路:
栈
class Solution {
public int longestValidParentheses(String s) {
int max = 0;
// 也可以使用 Stack<Integer> stack=new Stack<>();但Stack是遗留类,不推荐
Deque<Integer> stack = new LinkedList<>();
stack.push(-1);
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == '(') {
stack.push(i);
} else {
stack.pop();
if (stack.isEmpty()) stack.push(i);
else max = Math.max(max, i - stack.peek());
}
}
return max;
}
}




![TMC4671超越传感器和摄像头之外——将物联网从云端转移到现实世界[应用案例]](https://img-blog.csdnimg.cn/img_convert/1e97250e1597659d40466681f56c6767.jpeg)






070:判断是不是平衡二叉树071:最大子矩阵072:小葱的01串](https://img-blog.csdnimg.cn/direct/a2ae1a81d03c468588bd205ded2ade49.png)







