JAVA Simple Logic and less code
Please Upvote IF You Find This Helpful\n\nclass Solution {\n    public String removeDuplicates(String s) {\n        Stack<Character> st = new Stack<>();\n      
# Please Upvote IF You Find This Helpful\n```\nclass Solution {\n    public String removeDuplicates(String s) {\n        Stack<Character> st = new Stack<>();\n        for (int i = 0; i < s.length(); i++) {\n            if (!st.empty() && st.peek() == s.charAt(i)) st.pop();\n            else st.push(s.charAt(i));\n        }\n        StringBuilder ans = new StringBuilder();\n        while (!st.empty()) ans.append(st.pop());\n        return ans.reverse().toString();\n    }\n}\n```\n# Please Upvote IF You Find This Helpful
['String', 'Stack', 'Java']