Skip to content

Commit d929b71

Browse files
authored
Update longest_valid_parenthesis.py
added longest_valid_parenthesis.py
1 parent 5fc6444 commit d929b71

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

strings/longest_valid_parenthesis.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ def longest_valid_parenthesis(self, s: str) -> int:
55
2
66
>>> longest_valid_parenthesis(')()())')
77
4
8-
>>> longest_valid_parenthesis('')
9-
0
8+
>>> longest_valid_parenthesis('(()()()()))')
9+
10
1010
>>> longest_valid_parenthesis(''(())))((()(()()()())
1111
8
1212
"""
@@ -24,13 +24,9 @@ def longest_valid_parenthesis(self, s: str) -> int:
2424
res = max(res, preceeding_matched)
2525
preceeding_matched = 0
2626
res = max(res, preceeding_matched)
27-
2827
while stack:
2928
res = max(res, stack.pop())
3029
return res * 2
31-
32-
3330
if __name__ == "__main__":
3431
from doctest import testmod
35-
3632
testmod()

0 commit comments

Comments
 (0)