File tree 2 files changed +30
-1
lines changed
2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 1
- # 1,420 LeetCode solutions in JavaScript
1
+ # 1,421 LeetCode solutions in JavaScript
2
2
3
3
[ https://leetcodejavascript.com ] ( https://leetcodejavascript.com )
4
4
1244
1244
1609|[ Even Odd Tree] ( ./solutions/1609-even-odd-tree.js ) |Medium|
1245
1245
1610|[ Maximum Number of Visible Points] ( ./solutions/1610-maximum-number-of-visible-points.js ) |Hard|
1246
1246
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|
1247
1248
1657|[ Determine if Two Strings Are Close] ( ./solutions/1657-determine-if-two-strings-are-close.js ) |Medium|
1248
1249
1668|[ Maximum Repeating Substring] ( ./solutions/1668-maximum-repeating-substring.js ) |Easy|
1249
1250
1669|[ Merge In Between Linked Lists] ( ./solutions/1669-merge-in-between-linked-lists.js ) |Medium|
Original file line number Diff line number Diff line change
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
+ } ;
You can’t perform that action at this time.
0 commit comments