C++ | Without using stack | Easy to Understand
Intution\n 1. Add closing bracket to answer string when count of open bracket is greater than closing bracket.\n 2. Remove the extra open bracket from the answe
**Intution**\n **1.** Add closing bracket to answer string when count of open bracket is greater than closing bracket.\n **2.** Remove the extra open bracket from the answer string.\n  \n```\nclass Solution {\npublic:\n    string minRemoveToMakeValid(string s) {\n        string ans="";                                        // Create Empty string to store characters \n        int c1=0;                                              // store Count of open brackets\n        int c2=0;                                             //Store count of closing bracket\n        for(int i=0;i<s.size();i++)\n        {\n            if(s[i]==\'(\')\n            {\n                c1++;\n                ans+=s[i];\n            }\n            else if(s[i]==\')\')\n            {\n                if(c1>c2)      //Adding closing bracket to asnwer string when count of opening bracket greater than the closing bracket\n                {\n                    ans+=s[i];\n                    c2++;\n                }\n            }\n            else{\n                ans+=s[i];\n            }\n        }\n\t\t/* Answer string may contain extra open brackets so we have to remove the extra open brackets*/\n        string p="";              \n        c1=0;\n        for(int i=0;i<ans.size();i++)        //For Example answer string may be ans="(a(a(b)vd)"\n        {\n               if(ans[i]==\'(\' && c1<c2)      // Add only c2 no. of open brackets to the final string\n               {\n                   p+=ans[i];\n                   c1++;\n               }\n               else if(ans[i]!=\'(\')\n               {\n                   p+=ans[i];\n               }\n               \n        }\n        return p;\n    }\n};\n```
['String']