using Stack || O(n)
logic i used : I looped over the string and push the element in to the stack but if the top of the stack matches the next element to be pushped i poped the top.
logic i used : I looped over the string and push the element in to the stack but if the top of the stack matches the next element to be pushped i poped the top.\n\n```\nclass Solution {\npublic:\n    string removeDuplicates(string s) {\n    stack<char> stack;\n        string str="";\n    \n        for(int i=0;i<s.length();i++){\n        \n            if(!stack.empty() && s[i]==stack.top())\n            {\n                stack.pop();\n            }\n            else\n            stack.push(s[i]);\n        }\n        while(!stack.empty()){\n            str+=stack.top();\n            stack.pop();\n        }\n        reverse(str.begin(),str.end());\n return str; }\n};\n
[]