Bird
0
0

Which data structure is best suited to store individual reviews for quick lookup by product ID?

easy📝 Conceptual Q12 of 15
LLD - Design — Food Delivery System
Which data structure is best suited to store individual reviews for quick lookup by product ID?
AHash map with product ID as key and list of reviews as value
BArray of reviews without indexing
CLinked list of all reviews
DStack of reviews
Step-by-Step Solution
Solution:
  1. Step 1: Consider lookup efficiency

    Quick lookup by product ID requires a data structure with fast key-based access.
  2. Step 2: Choose appropriate structure

    A hash map (dictionary) allows O(1) average time to find reviews by product ID.
  3. Final Answer:

    Hash map with product ID as key and list of reviews as value -> Option A
  4. Quick Check:

    Fast lookup = Hash map [OK]
Quick Trick: Use hash maps for fast key-based lookup [OK]
Common Mistakes:
  • Using arrays without indexing causes slow searches
  • Linked lists have O(n) lookup time
  • Stacks do not support direct lookup by key

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes