Leetcode in Java && Oracle
422 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2021-11-07_04-36-36.png
30.3 KB
#N1614. Maximum Nesting Depth of the Parentheses
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;
}
}