Junior — Senior
Collection and sorting of numerical values
livecode
Task condition
Implement the GroupedCounterAlgorithm class, which provides the following operations:
- Method execute(long[] numbers)
- Analyze the input array numbers and determine which values are present.
- Form a
Map<Long, Long>structure, where:- key – a specific number from the array;
- value – the number of its occurrences.
- Method sort()
- Sort the formed map in descending order by key (i.e., from the largest number to the smallest).
- Method get()
- Return the already sorted
Map<Long, Long>.
- Return the already sorted
public class GroupedCounterAlgorithm implements Algorithm<long[], Map<Long, Long>> {
@Override
public Algorithm<long[], Map<Long, Long>> execute(long[] numbers) {
return null;
}
@Override
public Algorithm<long[], Map<Long, Long>> sort() {
return null;
}
@Override
public Map<Long, Long> get() {
return null;
}
}