You are viewing a single comment's thread. Return to all comments →
Comparator<Long> longComparator = Long::compare; Map<Integer, Long> valueMap = arr.stream().collect(Collectors.groupingBy(s -> s, Collectors.counting())); List<Long> values = valueMap.values().stream().sorted(longComparator.reversed()).collect(Collectors.toList()); long mostrepeated = values.get(0); long totaloccurences= values.stream().mapToLong(s->s).sum(); return (int)(totaloccurences - mostrepeated);
Seems like cookies are disabled on this browser, please enable them to open this website
Equalize the Array
You are viewing a single comment's thread. Return to all comments →