You are viewing a single comment's thread. Return to all comments →
My Java 8 Solution:
public static int lonelyinteger(List<Integer> a) { Set<Integer> set = new HashSet<>(); for (int number : a) { boolean isAdded = set.add(number); if (!isAdded) { set.remove(number); } } return set.iterator().next(); }
Seems like cookies are disabled on this browser, please enable them to open this website
Lonely Integer
You are viewing a single comment's thread. Return to all comments →
My Java 8 Solution: