https://leetcode.com/problems/valid-parentheses/#/description
class Solution(object):
def isValid(self, s):
"""
:type s: str
:rtype: bool
"""
stab='(){}[]'
tab=[0]*(len(stab)/2)
pos=0
smap={}
ssig={}
fills=[]
for c in stab:
smap[c]=pos/2
ssig[c]=1-2*(pos%2)
pos+=1
for c in s:
pos=smap[c]
tab[pos]+=ssig[c]
if ssig[c]<0:
if len(fills)==0 or fills[-1]!=pos:
return False
fills=fills[:-1]
else:
fills.append(pos)
if len(fills)!=0: return False
return True