https://leetcode-cn.com/problems/valid-parentheses/
func isValid(s string) bool { n := len(s) if n%2 != 0 { return false } f := func(a, b byte) bool { return (a == "{"[0] && b == "}"[0]) || (a == "["[0] && b == "]"[0]) || (a == "("[0] && b == ")"[0]) } stack := []byte{} for i := 0; i < n; i++ { if len(stack) == 0 { } else { b := f(stack[len(stack)-1], s[i]) if b { stack = stack[0 : len(stack)-1] continue } } stack = append(stack, s[i]) } return len(stack) == 0 }