Generate a Cent-Exact Fixed-Rate Mortgage Amortization Schedule

Last updated: November 29, 2026

Quick Overview

Given a principal, an annual interest rate and a term in months, produce the monthly schedule of payment, interest, principal and remaining balance for a fixed-rate mortgage. Every amount must be rounded to cents and the loan must end at exactly zero.

Valon
Coding & Algorithms
Software Engineer
Valon
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given a principal, an annual interest rate and a term in months, produce the monthly schedule of payment, interest, principal and remaining balance for a fixed-rate mortgage. Every amount must be rounded to cents and the loan must end at exactly zero.

A warm-up in the style of a Valon phone screen: amortization is the backbone of every loan record in ValonOS, and borrowers and investors see these numbers directly. The interviewer checks whether you avoid floats, apply rounding consistently and handle the final-payment true-up instead of leaving a stray cent of balance.

What the Interviewer Expects
  • Derive the level payment formula P*r/(1-(1+r)^-n) and handle a zero rate
  • Use Decimal or integer cents, never binary floats, for money
  • Round interest each month with an explicit rounding mode
  • Adjust the final payment so the balance lands at exactly zero
  • Return a clear structure and test with a known case such as $200,000 at 6% for 30 years
Key Topics to Cover
Amortization
Decimal arithmetic
Rounding modes
Final payment true-up
Fixed-rate mortgages
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 handle a biweekly payment plan?
  • What changes if the borrower makes a $10,000 curtailment in month 24: recast or shorter term?
  • How do you compute the schedule for an adjustable-rate loan when the rate resets?
  • Why might your schedule differ by a cent from the note's stated payment, and who wins?
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: principal (e.g. 200000), annual rate (0.06), term (360). Output one row per month: number, payment, interest, principal, ending balance. Money is in dollars to two decimals. Interest is monthl...

High-Level Design
  1. Compute the monthly rate r = annual/12.
  2. Compute the level payment with the annuity formula and round it once to cents. That rounded figure is what the borrower is billed.
  3. Walk month by month:...

Submit Your Answer
Markdown supported

Related Questions