✅✅Faster || Easy To Understand || C++ Code
Using Stack\n\n Time Complexity :- O(N)\n\n Space Complexity :- O(N)\n\n\nclass Solution {\npublic:\n    string removeDuplicates(string str) {\n        \n      
* ***Using Stack***\n\n* ***Time Complexity :- O(N)***\n\n* ***Space Complexity :- O(N)***\n\n```\nclass Solution {\npublic:\n    string removeDuplicates(string str) {\n        \n        int n = str.size();\n        \n        string res = "";\n        \n        for(int i = 0; i < n; i++)\n        {\n            if(res.size() > 0 && str[i] == res.back())\n            {\n                res.pop_back();\n            }\n            else \n            {\n                res.push_back(str[i]);\n            }\n        }\n        \n        return res;\n    }\n};\n```
['Stack', 'C', 'C++']