[go] stack
https://github.com/iamslash/learntocode/blob/master/leetcode/MinimumRemovetoMakeValidParentheses/a.go\n\n\n// 4ms 98.97% 6MB 100.00%\n// stack\n// O(N) O(N)\nfu
https://github.com/iamslash/learntocode/blob/master/leetcode/MinimumRemovetoMakeValidParentheses/a.go\n\n```\n// 4ms 98.97% 6MB 100.00%\n// stack\n// O(N) O(N)\nfunc minRemoveToMakeValid(s string) string {\n\tstck := []int{}\n\tbs := []byte(s)\n\tfor i, b := range bs {\n\t\tif b == \'(\' {\n\t\t\tstck = append(stck, i)\n\t\t} else if b == \')\' {\n\t\t\tif len(stck) > 0 {\n\t\t\t\tstck = stck[:len(stck)-1]\n\t\t\t} else {\n\t\t\t\tbs[i] = \'*\'\n\t\t\t}\n\t\t}\n\t}\n\tfor len(stck) > 0 {\n\t\tbs[stck[len(stck)-1]] = \'*\'\n\t\tstck = stck[:len(stck)-1]\n\t}\n\treturn strings.ReplaceAll(string(bs), "*", "")\n}\n```
[]