Allocate an Incoming Mortgage Payment Through a Servicing Waterfall

Last updated: November 29, 2026

Quick Overview

Write a function that applies a borrower payment plus any existing suspense balance to a loan's past-due installments, outstanding fees and principal according to a servicing waterfall. Partial installments must be held in suspense rather than split.

Valon
Coding & Algorithms
Software Engineer
Valon
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Write a function that applies a borrower payment plus any existing suspense balance to a loan's past-due installments, outstanding fees and principal according to a servicing waterfall. Partial installments must be held in suspense rather than split.

Payment allocation is one of the tasks ValonOS automates for servicers, and getting it wrong changes a homeowner's delinquency status. In a Valon-style technical screen the interviewer wants clean handling of money in cents, the rule that only whole installments advance the due date, and a clear order of operations you can defend.

What the Interviewer Expects
  • Represent all money as integer cents
  • Apply whole installments oldest first and advance the due date only for full installments
  • Hold leftover funds in suspense while the loan is still delinquent
  • Pay fees only after the loan is current, never ahead of principal and interest
  • Send any remainder on a current loan to principal curtailment
  • Return an auditable allocation breakdown
Key Topics to Cover
Payment waterfall
Suspense accounting
Integer cents
Delinquency
Idempotency
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you support an investor whose guide applies escrow before interest?
  • How do you reverse this allocation when the payment comes back NSF two days later?
  • What if the borrower explicitly instructs that extra funds go to escrow instead of principal?
  • How do you make this function safe to retry if the payment event is delivered twice?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Inputs, all in cents: the payment amount, the current suspense balance, a list of due installments oldest first (each with interest, principal and escrow components), and a list of outstanding fees. R...

High-Level Design

A pure function returning (allocation, new_suspense, remaining_installments, remaining_fees). Keeping it pure means the caller can persist the allocation as ledger entries in one transaction keyed b...


Submit Your Answer
Markdown supported

Related Questions