Workday Interview Question

Asked me very basic Object-Oriented Programming concepts (inheritance, classes, etc). Then they asked me to write a program that outputs the letter in a string that repeats first.

Interview Answer

Anonymous

Oct 11, 2013

Program that outputs the letter in a string that repeats first. HashSet set = new HashSet (); for(int i = 0; i < str.length; i++) { if(!set.add(str.charAt(i)) { System.out.println(str.charAt(i)); break; } }

1