Repository navigation
chapter_stack_and_queue/exercises/ #1940
Replies: 2 comments
def isValid(s):
if len(s) % 2 != 0:
return False
st = []
mp = {')':'(', ']':'[', '}':'{'}
for c in s:
if c not in mp:
st.append(c)
elif not st or st.pop() != mp[c]:
return False
return not st |
0 replies
|
还没学哈希表诶。但也能写 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
chapter_stack_and_queue/exercises/
动画图解、一键运行的数据结构与算法教程
https://www.hello-algo.com/chapter_stack_and_queue/exercises/
All reactions