1614. 括号的最大嵌套深度
class Solution {
public int maxDepth(String s) {
Stack<Character> stack=new Stack<>();
int max=0;
int count=0;
for(int i=0;i<s.length();i++){
if(s.charAt(i)=='('){
stack.add('(');
count++;
}else if(s.charAt(i)==')'&&!stack.isEmpty()){
max=Math.max(max,count);
count--;
stack.pop();
}
}
return max;
}
}
//(1223)))))