Skip to content

Commit 38e2790

Browse files
authored
Update longest_valid_paranthesis.py
added the necessary changes!
1 parent 4ef0c9a commit 38e2790

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

strings/longest_valid_paranthesis.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
def longest_valid_paranthesis(self, s: str) -> int:
1+
def longest_valid_parenthesis(self, s: str) -> int:
22
"""
33
Returns the length of the longest valid paranthesis
4-
>>> longest_valid_paranthesis('(()')
4+
>>> longest_valid_parenthesis('(()')
55
2
6-
>>> longest_valid_paranthesis(')()())')
6+
>>> longest_valid_parenthesis(')()())')
77
4
8-
>>> longest_valid_paranthesis('')
8+
>>> longest_valid_parenthesis('')
99
0
10-
>>> longest_valid_paranthesis(''(())))((()(()()()())
10+
>>> longest_valid_parenthesis(''(())))((()(()()()())
1111
8
1212
"""
1313
stack = []
@@ -28,9 +28,6 @@ def longest_valid_paranthesis(self, s: str) -> int:
2828
while stack:
2929
res = max(res, stack.pop())
3030
return res * 2
31-
32-
3331
if __name__ == "__main__":
3432
from doctest import testmod
35-
3633
testmod()

0 commit comments

Comments
 (0)