Debug Pennies Lost in Daily Interest Accrual
Last updated: November 29, 2026
Quick Overview
Members report that interest posted to their high-yield savings is a few cents lower than the advertised rate implies. Given an accrual job that rounds daily interest with floats, find the bug, explain it, and write a corrected accrual function.
SoFi
November 29, 20260
0
0 solved
Members report that interest posted to their high-yield savings is a few cents lower than the advertised rate implies. Given an accrual job that rounds daily interest with floats, find the bug, explain it, and write a corrected accrual function.
SoFi markets a high-yield savings APY, so interest that does not reconcile with disclosures becomes a member trust and compliance issue quickly. The interviewer checks systematic debugging (reproduce with a known case, compare against a hand calculation) and knowledge of decimal arithmetic and rounding policy.
What the Interviewer Expects
- Reproduces with a concrete balance, rate and period and computes the expected value by hand
- Identifies per-day rounding as the main cause and binary floats as a second source of noise
- Accrues at full precision and rounds once at posting time
- Uses Decimal and an explicit rounding mode agreed with finance
- Adds a regression test pinned to the hand-calculated value
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 might the bank choose ROUND_HALF_EVEN over ROUND_HALF_UP?
- How should accrual work when the balance changes mid-month?
- How would you backfill and pay members who were underpaid?
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
1000 \times 0.045 \times 31 / 365 \approx 3.8219$, which posts as 3.82. The job posts 3.72. Fix the computation so posted interest matches the discl...
High-Level Design
Debug by narrowing: one account, one month, print the daily values. Daily interest is about 0.123 dollars, and round(0.1233, 2) is 0.12, so every day throws away about 0.33 cents; over 31 days that ...