func isValid(s string) bool {
stack := []rune{}
for _, c := range s {
var cover rune
switch c {
case '(', '[', '{':
stack = append(stack, c)
continue
case ')':
cover = '('
case ']':
cover = '['
case '}':
cover = '{'
}
if len(stack) == 0 || stack[len(stack)-1] != cover {
return false
}
stack = stack[:len(stack)-1]
}
return len(stack) == 0
}