|
@@ -14,14 +14,16 @@ def isValid(s: str):
|
|
|
list = []
|
|
|
for i in s:
|
|
|
if i in dic.keys():
|
|
|
+ # 入栈
|
|
|
list.append(i)
|
|
|
else:
|
|
|
- # if len(list) ==0 or i != dic.get(list[-1]):
|
|
|
+ # 出栈
|
|
|
if len(list) == 0 or i != dic.get(list[-1]):
|
|
|
list.append(i)
|
|
|
else:
|
|
|
list.pop()
|
|
|
|
|
|
+ # 栈为空。意为括号都匹配结束
|
|
|
if len(list) == 0:
|
|
|
return True
|
|
|
else:
|
|
@@ -31,7 +33,11 @@ def isValid(s: str):
|
|
|
@pytest.mark.parametrize(
|
|
|
"s, expect",
|
|
|
[
|
|
|
- ("()[]", True)
|
|
|
+ # ("()[]", True),
|
|
|
+ # ("(({[])}", False),
|
|
|
+ # ("(]", False),
|
|
|
+ # ("([{}])", True),
|
|
|
+ ("21[o{00}j]", False)
|
|
|
]
|
|
|
)
|
|
|
def test_cases(s, expect):
|