#
#
# @param s string字符串
# @return bool布尔型
#
class Solution:
def isValid(self , s ):
# write code here
stack = [ ]
if len(s) == 1 or len(s)%2 !=0:
return False
else:
stack = []
dict ={'(':')','[':']','{':'}'}
for i in s:
if i in dict:
stack.append(dict.get(i))
else:
if stack:
if i== stack[-1]:
stack.pop()
if len(stack)==0:
return True
else:
return False 
京公网安备 11010502036488号