Question bank › Hashing
Dsa Hashing Hard

Unique Purchase Combinations

You are given a list of transactions where each transaction consists of a username and a list of items purchased in that transaction. Your task is to determine the number of unique combinations of items purchased by each user across all their transactions. A combination is considered unique if it contains a different set of items (order does not matter). Print the count of unique combinations for each user in the format: {username}: {count}. Input Format: - The first line contains an integer n (1 <= n <= 1000): number of transactions. - The next n lines each contain a string username followed by a list of item names (space-separated). Output Format: - Print the unique combination count for each user, one per line in the order of first appearance. Example: Input: 3 alice apple banana alice banana orange bob apple Output: alice: 2 bob: 1

Key concepts

hashingcombinationstransactions

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.