Java Solution using Stack
If the top of the stack has the same character as the current character of String at position i, keep popping from the stack.\n Otherwise, push the element onto
* If the top of the stack has the same character as the current character of String at position i, keep popping from the stack.\n* Otherwise, push the element onto the stack.\n* If the stack is not empty, pop all elements and store them in a StringBuilder, reverse it and return the result.\n```\npublic String removeDuplicates(String S) {\n        if(S == null || S.length() == 0)\n            return new String();\n        Stack<Character> stack = new Stack();\n        StringBuilder sb = new StringBuilder();\n        for(int i = 0; i < S.length(); i++) {\n            if(!stack.isEmpty() && stack.peek() == S.charAt(i))\n                while(!stack.isEmpty() && stack.peek() == S.charAt(i))\n                    stack.pop();\n            else\n                stack.push(S.charAt(i));\n        }\n        while(!stack.isEmpty())\n            sb.append(stack.pop());\n        return sb.reverse().toString();\n    }\n```
[]