Skip to content

Commit c0db571

Browse files
committed
Runtime: 74 ms (Top 48.14%) | Memory: 14.8 MB (Top 24.60%)
1 parent 5c0ad84 commit c0db571

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
# Runtime: 74 ms (Top 48.14%) | Memory: 14.8 MB (Top 24.60%)
12
class Solution:
23
def longestValidParentheses(self, s: str) -> int:
3-
4+
45
maxi = 0
56
stack = [-1]
6-
7+
78
for i in range(len(s)) :
89
if s[i] == "(" : stack.append(i)
910
else :
1011
stack.pop()
1112
if len(stack) == 0 : stack.append(i)
1213
else : maxi = max(maxi, i - stack[-1])
13-
14-
return maxi
14+
15+
return maxi

0 commit comments

Comments
 (0)