Question bank › Hashing
Dsa Hashing Easy

Common Favorite Products

You are designing a system for an e-commerce platform that allows users to save their favorite products. Given two lists of products from two different users, your task is to find and return the common favorite products between both users. Input Format: - The first line contains an integer A, the number of products for User A. - The second line contains integer B, the number of products for User B. - The next A lines contain the product IDs of User A. - The following B lines contain the product IDs of User B. Output Format: - Print each common favorite product ID, one per line, in sorted order. Example Input: 5 4 P1 P2 P3 P4 P5 P3 P4 P6 P7 Example Output: P3 P4

Key concepts

hashingsetsintersection

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.