JAVA | Remove All Adjacent Duplicates in String || Java Simple Solution using Stack
\nclass Solution {\n\n\n    public String removeDuplicates(String s) {\n        Stack stack = new Stack<>();\n        stack.push(s.charAt(0));\n        for(int 
\nclass Solution {\n\n\n    public String removeDuplicates(String s) {\n        Stack<Character> stack = new Stack<>();\n        stack.push(s.charAt(0));\n        for(int i=1;i<s.length();i++){\n            char c = s.charAt(i);\n\t\t\t// if stack is empty or the top element of the stack is not current we have then push into the stack\n            if(stack.isEmpty() || stack.peek() != c){\n                stack.push(c);\n            }// otherwise pop from the stack\n\t\t\telse{\n                stack.pop();\n            }\n        }\n\t\t// pop all the element which is left in the stack and store into the string and return;\n        String ans="";\n        while (!stack.isEmpty()){\n            ans=stack.pop()+ans;\n        }\n        return ans;\n        \n    }\n}\n\n<<<<<<<<<<<<   Please upvote.. if it is useful :)  >>>>>>>>>>>>>\n<<<<<<<<<<<<   Happy coding :)   >>>>>>>>>>>>>>>>>>>>>>>
['Stack', 'Java']