Skip to content

Commit

Permalink
1614
Browse files Browse the repository at this point in the history
  • Loading branch information
isinsuarici committed Jan 18, 2022
1 parent 155c1a0 commit 18f1484
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions E_1614_MaximumNestingDepthoftheParentheses.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class Solution {
public int maxDepth(String s) {
int depth = 0;
int max = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == '(') depth++;
else if (s.charAt(i) == ')') depth--;
max = Math.max(depth, max);
}
return max;

}
}

0 comments on commit 18f1484

Please sign in to comment.