#501 Counting Number Frequency in a List

Companies:
Sberbank
Themes:
JavaCollections & GenericsPractice

Count the frequency of numbers:

Java
public static void main(String[] args) {
    List<Integer> list = List.of(1, 2, 3, 1, null, 2, 1, null, 3);
    System.out.println("Frequencies: " + countNumberFrequency(list));
}

//Java 8
public static Map<Integer, Integer> countNumberFrequency(List<Integer> numbers) {
    // todo return null;
}

Additionally, sort by values.

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in