fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. Scanner in=new Scanner(System.in);
  14. HashMap<Character,Integer> hm=new HashMap<>();
  15. String str=in.nextLine();
  16. for(int i=0;i<str.length();i++)
  17. {
  18. char ch=str.charAt(i);
  19. if(hm.containsKey(ch))
  20. {
  21. hm.put(ch,hm.get(ch)+1);
  22. }
  23. else
  24. {
  25. hm.put(ch,1);
  26. }
  27. }
  28. for(Map.Entry<Character,Integer> e:hm.entrySet())
  29. {
  30. if(e.getValue()==1)
  31. {
  32. System.out.print(e.getKey());
  33. break;
  34. }
  35. }
  36. }
  37. }
Success #stdin #stdout 0.1s 35496KB
stdin
aman
stdout
m