Bird
0
0

You have a group with net balances: Dave: +70, Emma: -50, Frank: -20. How would you apply the simplify debts algorithm to minimize transactions and what are the transactions?

hard📝 Trade-off Q15 of 15
LLD - Design — Splitwise (Expense Sharing)
You have a group with net balances: Dave: +70, Emma: -50, Frank: -20. How would you apply the simplify debts algorithm to minimize transactions and what are the transactions?
AEmma pays Frank 20, Frank pays Dave 50 (2 transactions)
BDave pays Emma 50, Dave pays Frank 20 (2 transactions)
CEmma pays Dave 70, Frank pays Emma 0 (2 transactions)
DEmma pays Dave 50, Frank pays Dave 20 (2 transactions)
Step-by-Step Solution
Solution:
  1. Step 1: Identify creditors and debtors

    Dave is owed 70, Emma owes 50, Frank owes 20.
  2. Step 2: Match debtors to creditor to minimize transactions

    Emma pays Dave 50, Frank pays Dave 20, totaling 2 transactions.
  3. Final Answer:

    Emma pays Dave 50, Frank pays Dave 20 (2 transactions) -> Option D
  4. Quick Check:

    Debtors pay creditor directly = 2 transactions [OK]
Quick Trick: Debtors pay creditor amounts equal to their debts [OK]
Common Mistakes:
  • Reversing payer and receiver roles
  • Assigning incorrect amounts
  • Adding unnecessary transactions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes