Skip to content

Commit 1255f3b

Browse files
committed
Add solution #1614
1 parent 365ba17 commit 1255f3b

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1,420 LeetCode solutions in JavaScript
1+
# 1,421 LeetCode solutions in JavaScript
22

33
[https://leetcodejavascript.com](https://leetcodejavascript.com)
44

@@ -1244,6 +1244,7 @@
12441244
1609|[Even Odd Tree](./solutions/1609-even-odd-tree.js)|Medium|
12451245
1610|[Maximum Number of Visible Points](./solutions/1610-maximum-number-of-visible-points.js)|Hard|
12461246
1611|[Minimum One Bit Operations to Make Integers Zero](./solutions/1611-minimum-one-bit-operations-to-make-integers-zero.js)|Hard|
1247+
1614|[Maximum Nesting Depth of the Parentheses](./solutions/1614-maximum-nesting-depth-of-the-parentheses.js)|Easy|
12471248
1657|[Determine if Two Strings Are Close](./solutions/1657-determine-if-two-strings-are-close.js)|Medium|
12481249
1668|[Maximum Repeating Substring](./solutions/1668-maximum-repeating-substring.js)|Easy|
12491250
1669|[Merge In Between Linked Lists](./solutions/1669-merge-in-between-linked-lists.js)|Medium|
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* 1614. Maximum Nesting Depth of the Parentheses
3+
* https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses/
4+
* Difficulty: Easy
5+
*
6+
* Given a valid parentheses string s, return the nesting depth of s. The nesting depth is the
7+
* maximum number of nested parentheses.
8+
*/
9+
10+
/**
11+
* @param {string} s
12+
* @return {number}
13+
*/
14+
var maxDepth = function(s) {
15+
let currentDepth = 0;
16+
let maxDepth = 0;
17+
18+
for (const char of s) {
19+
if (char === '(') {
20+
currentDepth++;
21+
maxDepth = Math.max(maxDepth, currentDepth);
22+
} else if (char === ')') {
23+
currentDepth--;
24+
}
25+
}
26+
27+
return maxDepth;
28+
};

0 commit comments

Comments
 (0)