题解 | 括号配对问题
括号配对问题
https://www.nowcoder.com/practice/57260c08eaa44feababd05b328b897d7
import sys
a, s, t = "", "", []
for line in sys.stdin:
a = line.split()
for i in a[0]:
if i in "()[]":
s += i
for j in s:
if len(t) == 0:
t.append(j)
else:
t.pop(-1) if t[-1] + j in ["()", "[]"] else t.append(j)
print("true" if not t else "false")
