Bird
Raised Fist0

Given this simplified transaction record list:

medium📝 Analysis Q13 of Q15
LLD - Design — Splitwise (Expense Sharing)
Given this simplified transaction record list:
transactions = [
  {"id": "t1", "time": "2024-01-01T10:00:00Z"},
  {"id": "t2", "time": "2024-01-01T09:00:00Z"},
  {"id": "t3", "time": "2024-01-01T11:00:00Z"}
]

What is the correct order of transaction IDs if sorted by time ascending?
A["t1", "t2", "t3"]
B["t2", "t3", "t1"]
C["t3", "t1", "t2"]
D["t2", "t1", "t3"]
Step-by-Step Solution
Solution:
  1. Step 1: Analyze timestamps for each transaction

    t2 = 09:00, t1 = 10:00, t3 = 11:00 in UTC time.
  2. Step 2: Sort transactions by ascending time

    Order is t2 (earliest), then t1, then t3 (latest).
  3. Final Answer:

    ["t2", "t1", "t3"] -> Option D
  4. Quick Check:

    Sorted by time ascending = [t2, t1, t3] [OK]
Quick Trick: Sort by timestamp ascending for correct order [OK]
Common Mistakes:
MISTAKES
  • Sorting by ID instead of time
  • Confusing ascending with descending order
  • Ignoring timestamp format

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes