JAVA [NO STACK] solution O(n) Single pass
```\nclass Solution {\n    public String removeDuplicates(String S) {\n       StringBuilder sb = new StringBuilder();\n        int index = 0;\n       for(char c
```\nclass Solution {\n    public String removeDuplicates(String S) {\n       StringBuilder sb = new StringBuilder();\n        int index = 0;\n       for(char ch : S.toCharArray()){\n           if(sb.length() == 0){\n               sb.append(ch);\n              \n           }\n           else{\n               if(sb.charAt(index-1) == ch){\n                   sb.deleteCharAt(index-1);\n               }\n               else{\n                   sb.append(ch);\n               }\n           }\n            index = sb.length();\n           }\n        return sb.toString();\n    }\n}
['String', 'Java']