image_2021-11-07_04-36-36.png
30.3 KB
#N1614. Maximum Nesting Depth of the Parentheses
problem link
#solution
problem link
#solution
class Solution {
public int maxDepth(String s) {
int count=0, depth=0;
for(char ch:s.toCharArray()){
if(ch=='(')
count++;
if(ch==')'){
depth=Math.max(depth, count--);
}
}
return depth;
}
}