Stack || Java Easy Solution || Easy to Understand
\n\n# Approach\nWe compare our string character with the stack topmost element if both are same we remove the element from stack and move forward or else we jus
\n\n# Approach\nWe compare our string character with the stack topmost element if both are same we remove the element from stack and move forward or else we just push that element too into the stack.\n\n# Complexity\n- Time complexity: O(N)\n- N-> length of string\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n-  N-> length of String\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public String removeDuplicates(String s) {\n        Stack<Character> st = new Stack<>();\n        st.push(s.charAt(0));\n        for(int i = 1; i<s.length(); i++){\n            if(!st.isEmpty() && st.peek() == s.charAt(i)){\n                st.pop(); continue;\n            }\n            st.push(s.charAt(i));\n        }\n        StringBuilder sb = new StringBuilder();\n        while(!st.isEmpty()){\n            sb.append(st.pop());\n        }\n        return String.valueOf(sb.reverse());\n    }\n}\n```
['String', 'Stack', 'Java']