Bird
Raised Fist0

How would you combine percentage and exact split strategies in a system to handle complex billing scenarios?

hard📝 Trade-off Q9 of Q15
LLD - Design — Splitwise (Expense Sharing)
How would you combine percentage and exact split strategies in a system to handle complex billing scenarios?
AConvert all splits to equal shares internally
BAllow users to specify exact amounts and percentages, then validate total matches
CForce all splits to be either exact or percentage, not both
DIgnore exact splits and use only percentage splits
Step-by-Step Solution
Solution:
  1. Step 1: Support mixed input types

    Allow users to input both exact amounts and percentages for flexibility.
  2. Step 2: Validate combined splits

    Ensure the sum of exact amounts plus percentage shares equals total amount.
  3. Final Answer:

    Allow users to specify exact amounts and percentages, then validate total matches -> Option B
  4. Quick Check:

    Mixed splits need validation for correctness [OK]
Quick Trick: Validate combined splits sum to total amount [OK]
Common Mistakes:
MISTAKES
  • Disallowing mixed splits
  • Converting all to equal shares
  • Ignoring validation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes