python | #括号序列#
括号序列
http://www.nowcoder.com/practice/37548e94a270412c8b9fb85643c8ccc2
# # # @param s string字符串 # @return bool布尔型 # class Solution: def isValid(self , s ): # write code here dic = {'(':')','{' :"}",'[':']'} first = [] for ss in s: if ss in dic.keys(): first.append(ss) if ss in dic.values(): if len(first) == 0: return False tem = first.pop() if ss == dic[tem]: continue else: return False return True if len(first)==0 else False