C++ Solution || Stack || Very Easy Understanding
Intuition\n Describe your first thoughts on how to solve this problem. \nfind an invalid bracket index and store in stack.\nwhile traversing stack remove that b
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nfind an invalid bracket index and store in stack.\nwhile traversing stack remove that bracket from string.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nstack\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$o(n)$$\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$o(n)$$\n\n# Code\n```\nclass Solution {\npublic:\n    string minRemoveToMakeValid(string s) {\n        stack<pair<char,int>> st;\n        int n = s.size();\n        for(int i=0;i<n;i++){\n            if(s[i]==\'(\'){\n                st.push({s[i],i});\n            }else if(s[i]==\')\') {\n                if(!st.empty()&&st.top().first==\'(\'){\n                    st.pop();\n                }else{\n                    st.push({s[i],i});\n                }\n            }\n        }\n        while(!st.empty()){\n            int top = st.top().second;\n            s.erase(s.begin()+top);\n            st.pop();\n        }\n        return s;\n    }\n};\n```
['String', 'Stack', 'C++']