CPP STACK SOL
\n\n\n# Code\n\nclass Solution {\npublic:\n    int minAddToMakeValid(string s) {\n        stack<char>st;\n        st.push(s[0]);\n        for(int i=1;i<s.size()
![UPvote.jpg](https://assets.leetcode.com/users/images/9632ff40-c308-4840-98f2-906dac7538e0_1684471830.8581393.jpeg)\n\n\n# Code\n```\nclass Solution {\npublic:\n    int minAddToMakeValid(string s) {\n        stack<char>st;\n        st.push(s[0]);\n        for(int i=1;i<s.size();i++){\n            if (!st.empty() && st.top() == \'(\' && s[i] == \')\') st.pop();\n            else st.push(s[i]);\n        }\n        return st.size();\n    }\n};\n```
['Stack', 'C++']