Skip to content

Commit 2555991

Browse files
authored
Update Valid Parentheses - Leetcode 20.py
1 parent b3899d0 commit 2555991

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Valid Parentheses - Leetcode 20.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ class Solution:
22
def isValid(self, s: str) -> bool:
33
hashmap = {")": "(", "}": "{", "]": "["}
44
stk = []
5+
56
for c in s:
67
if c not in hashmap:
78
stk.append(c)
@@ -14,3 +15,6 @@ def isValid(self, s: str) -> bool:
1415
return False
1516

1617
return not stk
18+
19+
# Time Complexity: O(n)
20+
# Space Complexity: O(n)

0 commit comments

Comments
 (0)