You are viewing a single comment's thread. Return to all comments →
Solution in Java
int resultIndex = 0; Collections.sort(a); for (int i = 1; i < a.size(); i++) { if (!Objects.equals(a.get(i), a.get(i - 1))) { if (i == a.size() - 1){ resultIndex = i; break; } if (!Objects.equals(a.get(i), a.get(i + 1))) { resultIndex = i; break; } } } return a.get(resultIndex);
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 →
Solution in Java