Question bank › Hashing
Dsa Hashing Easy

Warehouse Batch Verification

In a logistics warehouse, every box has a unique ID, and boxes are grouped into batches. For quality control, the manager needs to identify the first batch encountered in the records that contains exactly K unique box IDs. Input Format: The first line contains an integer K. The subsequent lines contain pairs of space-separated strings: BoxID and BatchID. Output Format: The BatchID of the first batch (by order of appearance in input) that contains exactly K unique box IDs. If no such batch exists, print nothing. Example: Input: 2 BX101 A BX102 B BX103 A BX104 C Output: A (Explanation: Batch A has boxes BX101 and BX103, which is exactly 2 boxes. Batch B and C only have 1.)

Key concepts

hashingsetsfrequency tracking

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.