Rearden Commerce Interview Question
21 Interview Reviews |
Back to all Rearden Commerce Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Senior QA Engineer(Mobile) at Rearden Commerce:
Write code to ignore duplicates in a string of characters. The interviewer was very specific with the language i was supposed to use(Java)
See more for this Rearden Commerce Senior QA Engineer(Mobile) Interview
Helpful Question?
Yes |
No
Inappropriate?
0 of 0 people found this helpful
by Jeremy:
if (in == null) return null;
char[] inAr = in.toCharArray();
Set<Integer> outSet = new HashSet<Integer>();
List<Integer> outList = new ArrayList<Integer>();
for (char ch : inAr) {
if (outSet.add((int) ch))
outList.add((int)ch);
}
char[] outAr = new char[outList.size()];
Iterator<Integer> it = outList.iterator();
for (int i = 0; it.hasNext(); i++) {
int outInt = it.next();
outAr[i] = (char)outInt;
}
return String.copyValueOf(outAr);
}