Sobes.tech
Junior — Senior

Collection and sorting of numerical values

livecode

Task condition

Implement the GroupedCounterAlgorithm class, which provides the following operations:

  1. 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.
  2. Method sort()
    • Sort the formed map in descending order by key (i.e., from the largest number to the smallest).
  3. Method get()
    • Return the already sorted Map<Long, Long>.
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;
    }
}