Question bank › Stack
Dsa Stack Hard

Inventory Stock Management

A retail store uses an inventory system where products can be added and removed from stock. Implement a function that processes a series of commands for adding and removing items while keeping track of the current stock level. Each command is either 'ADD item_id' or 'REMOVE item_id'. If an item_id is removed that is not currently in stock, ignore the command. Output the current unique items in stock after processing all commands. Input Format: - A series of commands, one per line, ending with an EOF. Output Format: - A set of unique current item_ids in stock. Example: Input: ADD 101 ADD 102 REMOVE 102 ADD 103 REMOVE 101 Output: {103}

Key concepts

stackdata managementinventory

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.