Bird
0
0

You need to design an inventory system that supports multiple warehouses and tracks stock per warehouse. Which data structure best supports this requirement?

hard📝 Trade-off Q8 of 15
LLD - Design — Online Shopping Cart
You need to design an inventory system that supports multiple warehouses and tracks stock per warehouse. Which data structure best supports this requirement?
AA nested dictionary with warehouse IDs as keys and item-quantity dictionaries as values
BA flat list of all items without warehouse info
CA single dictionary with item names as keys and total quantity as values
DA string listing all items and quantities
Step-by-Step Solution
Solution:
  1. Step 1: Understand requirement for per-warehouse tracking

    Each warehouse must have its own stock data separately.
  2. Step 2: Match data structure to requirement

    Nested dictionary allows warehouse IDs as keys, each mapping to item-quantity dictionaries.
  3. Final Answer:

    A nested dictionary with warehouse IDs as keys and item-quantity dictionaries as values -> Option A
  4. Quick Check:

    Per-warehouse stock = nested dictionary [OK]
Quick Trick: Use nested dictionaries for hierarchical inventory data [OK]
Common Mistakes:
  • Using flat list loses warehouse info
  • Single dictionary can't separate warehouses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes