Split an Escrow Payment Across Line Items to the Exact Cent
Last updated: November 29, 2026
Quick Overview
Given a total amount in cents and a list of non-negative weights (for example each escrow item's annual cost), split the total proportionally into integer cents so the parts sum exactly to the total. Distribute leftover cents deterministically.
Valon
November 29, 20260
0
0 solved
Given a total amount in cents and a list of non-negative weights (for example each escrow item's annual cost), split the total proportionally into integer cents so the parts sum exactly to the total. Distribute leftover cents deterministically.
Money that does not add up is a real defect in servicing: an escrow deposit split into tax, hazard and flood buckets must reconcile to the cent for statements and investor reports. Valon-style interviewers use this to check money handling fundamentals, determinism, and input validation.
What the Interviewer Expects
- Use integer arithmetic only
- Compute floor shares then distribute the remaining cents
- Use the largest-remainder rule with a deterministic tie-breaker
- Prove the parts sum to the total
- Validate empty, zero and negative inputs
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- Why is rounding each share independently wrong?
- How would you keep allocations stable month to month so the same item does not always get the extra cent?
- How would you split a negative amount, such as a reversal?
- Where else in a servicing platform does this pattern show up?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Input: total_cents (int >= 0) and weights (ints >= 0, not all zero). Output: a list of ints, same length, each proportional to its weight, summing exactly to the total. Ties broken by position so ...
High-Level Design
Rounding each share with round() can leave you a cent over or under: $1.00 across three equal items rounds to 33+33+33 = 99. Instead, take each floor share with exact integer division, compute how m...