Easy Solution using Stack
this problem is similar to\nhttps://leetcode.com/problems/make-the-string-great/solutions/2790887/daily-leetcoding-challenge-november-8-o-n-t-c/\n\n# Code\n\ncl
this problem is similar to\nhttps://leetcode.com/problems/make-the-string-great/solutions/2790887/daily-leetcoding-challenge-november-8-o-n-t-c/\n\n# Code\n```\nclass Solution {\npublic:\n    string removeDuplicates(string s) {\n        int n=s.length();\n        stack<char>st;\n        string ans="";\n        for(int i=0;i<n;i++){\n//if stack is empty push the element into stack\n            if(st.empty())\n                st.push(s[i]);\n            else \n//else check top element of stack is same of currunt element or not\n//if yes pop top elemnt and ignore this element (dont push into stack)\n                if(st.top()==s[i])\n                    st.pop();\n                else\n//otherwise push into the stack\n                   st.push(s[i]);\n        }\n         while(!st.empty()){\n             ans+=st.top();\n             st.pop();\n         }\n         reverse(ans.begin(),ans.end());\n         return ans;\n    }\n};\n```
['Stack', 'C++']