fork(2) download
  1. class FirstUniqueCharFinder {
  2.  
  3. static char find(String word) {
  4. int len = word.length();
  5. char firstUniqueChar = 0;
  6.  
  7. for (int i = 0; i < len; i++) {
  8. char currentChar = word.charAt(i);
  9. if (word.indexOf(currentChar, i + 1) == -1) {
  10. firstUniqueChar = currentChar;
  11. break;
  12. }
  13. }
  14.  
  15. return firstUniqueChar;
  16. }
  17.  
  18. public static void main(String[] args) {
  19. System.out.println(find("transaction"));
  20. System.out.println(find("reverse"));
  21. }
  22. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
r
v