fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. /* Name of the class has to be "Main" only if the class is public. */
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. ArrayList<String> arr = new ArrayList();
  11. Scanner input = new Scanner(System.in);
  12. String str,str2;
  13. String empty = "";
  14. str = input.nextLine();
  15. for(int i = 0;i<str.length();i++)
  16. {
  17. str2 = empty;
  18. str2 += str.charAt(i);
  19. arr.add(str2);
  20. }
  21. for(int i = 0;i < arr.size(); i++)
  22. {
  23. if(i != arr.size()-1)
  24. {
  25. if(arr.get(i).equals(arr.get(i+1)))
  26. {
  27. arr.remove(i);
  28. arr.remove(i);
  29. i--;
  30. }
  31. }
  32. }
  33. for(int i = 0;i < arr.size();i++)
  34. {
  35. System.out.print(arr.get(i));
  36. }
  37. }
  38. }
Success #stdin #stdout 0.09s 2841600KB
stdin
aabbccff
stdout
Standard output is empty