Dsa
Hashing
Medium
Popular Product Identifier
You are given a list of product IDs sold in a store. Your task is to identify the product ID that is sold the most frequently. If there are ties, return the product ID that is numerically smallest. If no products are sold, return 'No products sold'.
Input Format:
- The first line contains an integer n, the number of products sold.
- The next n lines each contain a single integer representing a product ID.
Output Format:
- Print the product ID that is sold the most frequently or 'No products sold' if n is 0.
Example:
Input:
5
101
202
101
303
202
Output:
101
Key concepts
hashingfrequencydictionary
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