You are viewing a single comment's thread. Return to all comments →
JAVA8 With stream (need stack to store a previus Item)
final Stack<Integer> stack=new Stack<>(); a.stream().sorted().filter((i)->{ if (stack.isEmpty()){stack.push(i);return false;} else if (stack.get(0).equals(i)){stack.pop();return false;} else return true; }).findFirst(); return stack.pop();
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 →
JAVA8 With stream (need stack to store a previus Item)