100% beats || c++ || stack
Code\n\nclass Solution {\npublic:\n    int minAddToMakeValid(string s) {\n        int ans = 0;\n        vector<char> v;\n        for(auto &i: s){\n            i
# Code\n```\nclass Solution {\npublic:\n    int minAddToMakeValid(string s) {\n        int ans = 0;\n        vector<char> v;\n        for(auto &i: s){\n            if(i==\'(\'){\n                v.push_back(i);\n            }else{\n                if(v.empty())ans++;\n                else{\n                    v.pop_back();\n                }\n            }\n        }\n        return ans+v.size();\n    }\n};\n```
['String', 'Stack', 'Greedy', 'C++']