Thursday, 22 August 2013

find element that is not duplicated in Array List using only 1 temp variable

find element that is not duplicated in Array List using only 1 temp variable

I have a scenario where i need to find the String element in Array list
that is not duplicate
List<String> myList=new ArrayList<String>();
myList.add("abcd");
myList.add("xyz");
myList.add("xyz");
myList.add("pqrs");
myList.add("pqrs");
And my answer should be "abcd" . I need to find this answer without using
any of the collections api , just using 1 temporary variable . Can anyone
help me on this.

No comments:

Post a Comment