func isValid(s string) bool {
leftMap := map[string]string{"(": "", "[": "", "{": ""}
r2lMap := map[string]string{")": "(", "]": "[", "}": "{"}
sQ := make([]string, 0,len(s))
for _, cB := range s {
cS := string(cB)
if _, ok := leftMap[cS]; ok {
sQ = append(sQ, cS)
} else {
trip := r2lMap[cS]
if len(sQ) < 1 {
return false
}
if sQ[len(sQ)-1] == trip {
if len(sQ) > 1 {
sQ = sQ[:len(sQ)-1]
} else if len(sQ) ==1{
sQ = []string{}
}else {
return false
}
} else {
return false
}
}
}
if len(sQ) > 0 {
return false
}
return true
}