✅C++ 100% faster & 90% memory efficient || easy single loop solution
Please upvote if you find this helpful \uD83D\uDE4F\n\n# Code\n\nclass Solution {\npublic:\n    int minAddToMakeValid(string s) {\n        int ans = 0;\n       
# Please upvote if you find this helpful \uD83D\uDE4F\n\n# Code\n```\nclass Solution {\npublic:\n    int minAddToMakeValid(string s) {\n        int ans = 0;\n        int open = 0;\n        int close = 0;\n\n        for(int j=0;j<s.length();j++){\n\n            if((open - close) == 0 && s[j] == \')\'){\n                    ans++;\n            }\n            else if(s[j] == \'(\')\n                open++;\n            else\n                close++;\n        }\n        ans += (open-close);\n        return ans;\n    }\n};\n```\n<B></B>\n<B></B>\n<B></B>\n##### Comment below if you didn\'t understand any steps\n
['C++']