MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / maxDepth

Method maxDepth

Java/max-nesting-depth-parentheses.java:2–19  ·  view source on GitHub ↗
(String s)

Source from the content-addressed store, hash-verified

1class Solution {
2 public int maxDepth(String s) {
3
4 int maxDepth = Integer.MIN_VALUE;
5 int depth = 0;
6
7 for(int i=0; i<s.length(); i++){
8
9 if(s.charAt(i) == '('){
10 depth++;
11 }
12 else if(s.charAt(i) == ')'){
13 depth--;
14 }
15 maxDepth = (depth > maxDepth) ? depth : maxDepth;
16 }
17
18 return maxDepth;
19 }
20}

Callers

nothing calls this directly

Calls 1

lengthMethod · 0.80

Tested by

no test coverage detected