Question bank › Hashing
Dsa Hashing Easy

Last Seen Items Tracking

You are developing a system that tracks the last seen items for multiple users. Given a series of item visits from users, print the last unique item each user visited. If a user visits the same item multiple times, only the most recent visit should be recorded. Input Format: - The first line contains an integer N, the number of visits. - The next N lines contain `user_id item_id`, where `user_id` is a string and `item_id` is also a string. Output Format: - For each unique user, print `user_id last_seen_item_id` in the order of their first appearance. Example Input: 5 U1 I1 U2 I2 U1 I3 U2 I1 U1 I1 Example Output: U1 I1 U2 I1

Key concepts

hashingtrackingrecent items

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.