Easy To Understand | C++ | Stack
Intuition\n Describe your first thoughts on how to solve this problem. \nSimple Use Of Stack\n\n# Code\n\nclass Solution {\npublic:\n    string removeDuplicates
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSimple Use Of Stack\n\n# Code\n```\nclass Solution {\npublic:\n    string removeDuplicates(string s) {\n        stack<int> p;\n        p.push(s[0]);\n        for(int i=1;i<s.size();i++){\n            if(!p.empty()){\n                if(s[i]==p.top()){\n                    p.pop();\n                }\n                else{\n                    p.push(s[i]);\n                }\n            }\n            else{\n                p.push(s[i]);\n            }\n        }\n        string r;\n        while(!p.empty()){\n            r+=p.top();\n            p.pop();\n        }\n        reverse(r.begin(), r.end());\n        return r;\n    }\n};\n```
['C++']