Two Solutions || O(1) Extra space|| Clean Code
Solution 1: Using Stack\n\nvar removeDuplicates = function(str){\n    var stack = [];\n    for(var s of str){\n        stack.push(s);\n        while(stack.lengt
**Solution 1: Using Stack**\n```\nvar removeDuplicates = function(str){\n    var stack = [];\n    for(var s of str){\n        stack.push(s);\n        while(stack.length > 1 && stack[stack.length-1] === stack[stack.length-2]){\n            stack.pop();\n            stack.pop();\n        }\n    }\n    return stack.join(\'\');\n}\n```\n**Solution 2: O(1) Space || Inplace string manipulation**\n```\nvar removeDuplicates = function(s) {\n    for(var i=1; i<s.length; i++){\n        if(s[i] === s[i-1]){\n            s = s.slice(0, i-1) + s.slice(i+1);\n            i-=2;\n        }\n    }\n    return s;\n};\n
['JavaScript']