Skip to content

Commit f3eb82d

Browse files
committed
Time: 3 ms (7.47%), Space: 41.7 MB (75.88%) - LeetHub
1 parent 1de4ab0 commit f3eb82d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public int maxDepth(String s) {
3+
Stack<Character> stack = new Stack<>();
4+
int max = 0, answer = 0;
5+
for(char x : s.toCharArray()){
6+
if(x == '(') stack.push(x);
7+
else if(x == ')') stack.pop();
8+
9+
max = Math.max(max, stack.size());
10+
}
11+
12+
return max;
13+
}
14+
}

0 commit comments

Comments
 (0)