You are viewing a single comment's thread. Return to all comments →
JAVA 8
public static int lonelyinteger(List<Integer> a) { List<Integer> newList = new ArrayList<Integer>(); if (a.size() <= 1) { return a.get(0); } else { Collections.sort(a); for (Integer item : a) { if (!newList.contains(item)) { newList.add(item); } else { newList.remove(item); } } return newList.get(0); } }
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 →
JAVA 8