0-ms |100% faster | C++ Solution
****\n```\nclass Solution {\npublic:\n    int minAddToMakeValid(string S) {\n        int i,n=S.size(),l=0,r=0,c=0;\n        for(i=0;i<n;i++)\n        {\n       
****\n```\nclass Solution {\npublic:\n    int minAddToMakeValid(string S) {\n        int i,n=S.size(),l=0,r=0,c=0;\n        for(i=0;i<n;i++)\n        {\n            if(S[i]==\'(\')\n            {\n                l++;\n            }\n            else\n            {\n                if(l==0)\n                {\n                    c++;\n                }\n                else\n                {\n                    l--;\n                }\n            }\n        }\n        \n        return l+c;\n        \n    }\n};\n\n\'\'\'\n
[]