Bird
0
0

Which data structure is most suitable for storing transaction history to allow fast retrieval by transaction ID?

easy📝 Conceptual Q2 of 15
LLD - Design — Splitwise (Expense Sharing)
Which data structure is most suitable for storing transaction history to allow fast retrieval by transaction ID?
AQueue
BLinked list
CStack
DHash map (dictionary)
Step-by-Step Solution
Solution:
  1. Step 1: Consider retrieval speed by transaction ID

    Fast lookup by ID requires constant time access, which hash maps provide.
  2. Step 2: Compare with other data structures

    Linked lists, stacks, and queues require linear search for ID lookup, which is slower.
  3. Final Answer:

    Hash map (dictionary) -> Option D
  4. Quick Check:

    Fast ID lookup = Hash map [OK]
Quick Trick: Use hash maps for fast key-based retrieval [OK]
Common Mistakes:
  • Choosing linked list for fast lookup
  • Confusing stack or queue with random access
  • Ignoring retrieval speed requirements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes