Question bank › Hashing
Dsa Hashing Easy

Product Frequency Count

You are given a list of integers, where each integer represents a product ID involved in sales transactions. Your task is to count the frequency of each product ID and return a list of product IDs sorted by their frequency in descending order. If two product IDs have the same frequency, return them sorted in ascending order. Input Format: The input will consist of a single line containing space-separated integers representing product IDs. Output Format: Print the sorted product IDs based on the criteria mentioned above in a single line, space-separated. Example: Input: 5 3 5 2 5 3 4 3 4 Output: 5 3 4 2

Key concepts

hashingcountingarrays

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.