Simple and short C++ solution
Approach:\nPush every occurrence of \'(\' into a stack and whenever \')\' appears in the string, try to pop \'(\' from stack if exists. If \'(\' does not exist,
**Approach:**\nPush every occurrence of \'(\' into a stack and whenever \')\' appears in the string, try to pop \'(\' from stack if exists. If \'(\' does not exist, then erase \')\' from string. After parsing the entire string, erase extra \'(\' present in stack from string.\n\n***Note***\n*Store indices of string in stack instead of the character for easy access and less iteration.*\n\n```\nclass Solution {\npublic:\n    string minRemoveToMakeValid(string s) {\n        stack<int> box;\n        int n = s.length();\n        \n        for(int i=0; i<n; i++) {\n            if(s[i] == \')\'){\n                if(!box.empty() && s[box.top()] == \'(\'){\n                    box.pop();\n                }else{\n                    s.erase(i,1);\n                    i--;\n                }\n            }\n            else if(s[i] == \'(\'){\n                box.push(i);\n            }\n        }\n        \n        while(!box.empty()) {\n            s.erase(box.top(),1);\n            box.pop();\n        }\n        \n        return s;\n    }\n};\n```\n\n***Hope it helps. :)***
['C']