Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Maximum Nesting Depth of the Parentheses
Bookmark
Stack
Counter
Input
Standard (depth=3)
Increasing depth
Depth 1
No parens
Custom
s
=
(1+(2*3)+((8)/4))+1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(
1
+
(
2
*
3
)
+
(
(
8
)
/
4
)
)
+
1
stack
maxDepth
0
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(
1
+
(
2
*
3
)
+
(
(
8
)
/
4
)
)
+
1
stack
maxDepth
0
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(
1
+
(
2
*
3
)
+
(
(
8
)
/
4
)
)
+
1
i
(
top
stack
maxDepth
1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(
1
+
(
2
*
3
)
+
(
(
8
)
/
4
)
)
+
1
i
(
(
top
stack
maxDepth
1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(
1
+
(
2
*
3
)
+
(
(
8
)
/
4
)
)
+
1
i
(
(
top
stack
maxDepth
2
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(
1
+
(
2
*
3
)
+
(
(
8
)
/
4
)
)
+
1
i
(
top
stack
maxDepth
2
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(
1
+
(
2
*
3
)
+
(
(
8
)
/
4
)
)
+
1
i
(
(
top
stack
maxDepth
2
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(
1
+
(
2
*
3
)
+
(
(
8
)
/
4
)
)
+
1
i
(
(
(
top
stack
maxDepth
3
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(
1
+
(
2
*
3
)
+
(
(
8
)
/
4
)
)
+
1
i
(
(
top
stack
maxDepth
3
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(
1
+
(
2
*
3
)
+
(
(
8
)
/
4
)
)
+
1
i
(
stack
maxDepth
3
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(
1
+
(
2
*
3
)
+
(
(
8
)
/
4
)
)
+
1
stack
return
3
algo
master
.
io
Step:
Start: track nesting depth with an explicit stack of open parens
0 / 44
Input
Standard (depth=3)
Increasing depth
Depth 1
No parens
Custom
s
=
(1+(2*3)+((8)/4))+1
0 / 44
algo
master
.
io
Step:
Start: track nesting depth with an explicit stack of open parens