Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7fb8d0c

Browse files
committed
Time: 36 ms (49.21%) | Memory: 16.4 MB (59.21%) - LeetSync
1 parent d8d75b0 commit 7fb8d0c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution:
2+
def maxDepth(self, s: str) -> int:
3+
stack = []
4+
maxi = 0
5+
for char in s:
6+
if char == '(':
7+
stack.append('(')
8+
if len(stack) > maxi:
9+
maxi = len(stack)
10+
11+
elif char == ')':
12+
if stack:
13+
stack.pop()
14+
return maxi

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /