C++ very easy solution using stack, Commented
\n\nclass Solution {\n\tpublic:\n    string minRemoveToMakeValid(string s) {\n        //to store value and its index\n\t\t\tstack<pair<int, int>> st;\n        s
```\n\nclass Solution {\n\tpublic:\n    string minRemoveToMakeValid(string s) {\n        //to store value and its index\n\t\t\tstack<pair<int, int>> st;\n        string temp;\n        for(int i = 0;i<s.size();i++)\n        {\n            //if we have to remove symbol, store some other symbol instead of this:\n            if(s[i] == \')\' && st.empty())\n                s[i] = \'{\';\n            else if(s[i] == \')\' && !st.empty())\n                st.pop();\n            else if(s[i] == \'(\')\n                st.push({s[i], i});\n                \n        }\n         \n        while(!st.empty())\n        {\n            s[st.top().second] = \'{\';\n            st.pop();\n        }\n        //store required string into some temp,don\'t include symbols which we have to remove.\n        for(int i = 0;i<s.size();i++)\n        {\n            if(s[i] != \'{\')\n                temp.push_back(s[i]);\n        }\n        return temp;\n    }\n};\n\n```
['Stack', 'C', 'C++']