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
Software Engineering Fundamentals
Software Engineer
Valon
November 29, 2026
Software Engineer
Phone Screen
Software Engineering Fundamentals
Easy

0

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
Money representation
Largest remainder method
Determinism
Input validation
Reconciliation
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported

Related Questions