No Stack Solution(Only String/StringBuilder) [C++ / Java]
C++\n\nclass Solution {\npublic:\n    string removeDuplicates(string S) {\n        string ans = "";\n        for (char ch: S) {\n            if ( ans.size() != 
**C++**\n```\nclass Solution {\npublic:\n    string removeDuplicates(string S) {\n        string ans = "";\n        for (char ch: S) {\n            if ( ans.size() != 0 and ans.back() == ch )\n                ans.pop_back();\n            else\n                ans.push_back(ch);\n        }\n        return ans;\n    }\n};\n```\n**Java**\n```\nclass Solution {\n    public String removeDuplicates(String S) {\n        StringBuilder sb = new StringBuilder();\n        for (char ch: S.toCharArray()) {\n            if ( sb.length() != 0 && sb.charAt(sb.length() - 1) == ch ) {\n                sb.deleteCharAt(sb.length() - 1);\n            } else {\n                sb.append(ch);\n            }\n        }\n        return sb.toString();\n    }\n}\n```\n**If you liked it, even a little bit then pls consider giving this solution a Upvote\nThank You :)**
['C', 'Java']