解题思路:
注意事项:
参考代码:
def func(s):
stack = []
mapping = {')': '('}
for char in s:
if char in mapping.values():
stack.append(char)
elif char in mapping.keys():
if not stack or mapping[char] != stack.pop():
return 'NO'
return "YES" if len(stack) == 0 else "NO"
expression = input()
result = func(expression + '@')
print(result)
0.0分
1 人评分