标签:rgb not false bsp class 一个 for end 判断
给定一个只包括 ‘(‘,‘)‘,‘{‘,‘}‘,‘[‘,‘]‘ 的字符串 s ,判断字符串是否有效。
dic = {‘{‘: ‘}‘, ‘[‘: ‘]‘, ‘(‘: ‘)‘}
stack = []
for c in s:
if c in dic: stack.append(c)
elif not stack or dic[stack.pop()] != c: return False
return not stack
标签:rgb not false bsp class 一个 for end 判断
原文地址:https://www.cnblogs.com/FANKIKI/p/14956609.html