Skip to content

Commit b8030b0

Browse files
add 1614
1 parent 00115e4 commit b8030b0

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|1614|[Maximum Nesting Depth of the Parentheses](https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1614.java) ||Easy|String|
1112
|1609|[Even Odd Tree](https://leetcode.com/problems/even-odd-tree/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1609.java) ||Medium|Tree|
1213
|1608|[Special Array With X Elements Greater Than or Equal X](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1608.java) ||Easy|Array|
1314
|1604|[Alert Using Same Key-Card Three or More Times in a One Hour Period](https://leetcode.com/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1604.java) ||Medium|String, Ordered Map|
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.fishercoder.solutions;
2+
3+
import java.util.Stack;
4+
5+
public class _1614 {
6+
public static class Solution1 {
7+
public int maxDepth(String s) {
8+
Stack<Character> stack = new Stack<>();
9+
int maxDepth = 0;
10+
for (char c : s.toCharArray()) {
11+
if (c == '(') {
12+
stack.push(c);
13+
} else if (c == ')') {
14+
maxDepth = Math.max(maxDepth, stack.size());
15+
stack.pop();
16+
}
17+
}
18+
return maxDepth;
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)