✅With stack. ~100% Easy ✅
Intuition\nPlease upvt if you found it useful\n\n# Complexity\n- Time complexity: O(N)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(N)\n
# Intuition\nPlease **upvt** if you found it useful\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\ntype stack struct {\n    top   int\n    v     []byte\n    index []int\n}\n\nfunc minRemoveToMakeValid(s string) string {\n    stc := stack{top: -1}\n\n    // collect bad brackets\n    for i, v := range s {\n        if v == \'(\' {\n            stc.v = append(stc.v, \'(\')\n            stc.index = append(stc.index, i)\n            stc.top++\n        } else if v == \')\' {\n            if stc.top > -1 && stc.v[stc.top] == \'(\' {\n                stc.v = stc.v[:stc.top]\n                stc.index = stc.index[:stc.top]\n                stc.top--\n            } else {\n                stc.v = append(stc.v, \')\')\n                stc.index = append(stc.index, i)\n                stc.top++\n            }\n        }\n    }\n\n    // remove them\n    res := []byte{}\n    i := 0\n    for _, v := range stc.index {\n        res = append(res, s[i:v]...)\n        i = v + 1\n    }\n\n    // checking of end\n    if len(res) + len(stc.index) < len(s) {\n        res = append(res, s[i:]...)\n    }\n\n    return string(res)\n}\n```
['Stack', 'Go']