This commit is contained in:
Gyubin Han
2025-02-19 14:09:55 +09:00
parent e3c6c8b32a
commit dede0dca01
36 changed files with 555 additions and 0 deletions

21
leetcode/20.py Normal file
View File

@@ -0,0 +1,21 @@
class Solution:
def isValid(self, s: str) -> bool:
arr=[]
for c in s:
if c in ['(','{','[']:
arr.append(c)
continue
if c in [')','}',']']:
if len(arr)<0+1:
return False
p=arr.pop()
if not((c==')' and p=='(') or (c=='}' and p=='{') or (c==']' and p=='[')):
return False
if len(arr)>0:
return False
else:
return True