Simple C++ solution (one pass) where we use string as a stack
Using string as a stack prevents the need for reversing which happens if we use a stack.\nSince the output string is not counted in space complexity, the space 
Using string as a stack prevents the need for reversing which happens if we use a stack.\nSince the output string is not counted in space complexity, the space complexity for the below code is O(1)\n```\nclass Solution {\npublic:\n    string removeDuplicates(string s) {\n        string ans;\n        for(int i=0;i<s.length();i++)\n        {\n            if(ans.length()==0 || ans.back()!=s[i])\n            {\n               ans.push_back(s[i]);\n               continue;\n            }\n            while(ans.length() >0 && ans.back() == s[i])\n            {\n                ans.pop_back();\n            }\n        }\n        return ans;\n    }\n};
['C']