C++ Super Simple O(n) Solution Using Stack
\nclass Solution {\npublic:\n    string minRemoveToMakeValid(string s) {\n        stack<int> stack;\n        int n = s.size();\n        \n        for (int i = 0
```\nclass Solution {\npublic:\n    string minRemoveToMakeValid(string s) {\n        stack<int> stack;\n        int n = s.size();\n        \n        for (int i = 0; i < n; i++) {\n            if (s[i] == \'(\') \n                stack.push(i);\n            \n            else if (s[i] == \')\') {\n                \n                if (!stack.empty()) {\n                    stack.pop();\n                }\n                    \n                else {\n                    s.erase(i, 1);\n                    i--;\n                }\n            }\n        }\n        \n        while (!stack.empty()) {\n            s.erase(stack.top(), 1);\n            stack.pop();\n        }\n        return s;\n    }\n};\n```\n**Like it? please upvote...**
['C']