"def is_valid(s: str) -> bool:
stack = []
closeToOpen = { ")" : "(", "]" : "[", "}" : "{" }
for c in s:
if c in closeToOpen:
if stack and stack[-1] == closeToOpen[c]:
stack.pop()
else:
return False
else:
stack.append(c)
return True if not stack else False
debug your code below
print(is_valid("()[]"))
`"
Anonymous Roadrunner - "def is_valid(s: str) -> bool:
stack = []
closeToOpen = { ")" : "(", "]" : "[", "}" : "{" }
for c in s:
if c in closeToOpen:
if stack and stack[-1] == closeToOpen[c]:
stack.pop()
else:
return False
else:
stack.append(c)
return True if not stack else False
debug your code below
print(is_valid("()[]"))
`"See full answer
"using a relational database isn't a good choice for this system! we need more availability here than consistency (CAP theorem)"
Anonymous Capybara - "using a relational database isn't a good choice for this system! we need more availability here than consistency (CAP theorem)"See full answer