Build a Biweekly Installment Plan with Partial Refunds
Last updated: November 29, 2026
Quick Overview
Split a point-of-sale purchase into n biweekly installments in integer cents (first payment due at checkout), then apply a partial merchandise refund by reducing unpaid installments from the last one backward and report any amount that must go back to the card.
Onepay
November 29, 20260
0
0 solved
Split a point-of-sale purchase into n biweekly installments in integer cents (first payment due at checkout), then apply a partial merchandise refund by reducing unpaid installments from the last one backward and report any amount that must go back to the card.
OnePay offers pay-over-time installment loans at Walmart checkout, so lending engineers deal with schedules, rounding, and returns every day. The interviewer checks that every cent is accounted for, that the refund rule is explicit, and that you can reason about what was already collected.
What the Interviewer Expects
- Installment amounts sum exactly to the purchase total
- Leftover cents land on a deterministic installment, stated up front
- Refunds reduce unpaid installments without touching paid ones
- Refund beyond the unpaid balance is returned to the payer, not dropped
- Validate inputs such as zero installments or non-positive totals
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Some lenders spread a refund evenly across remaining installments instead. What does that change for the customer and for the code?
- How do you handle a refund that arrives while an installment payment is mid-flight at the bank?
- How would you model the schedule in a database so it survives refunds, reschedules, and late fees?
- What changes for a monthly plan where due dates must avoid the 29th to 31st?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Given total cents, number of installments n, and a purchase date, produce n [due_date, cents] entries 14 days apart, with the first due at checkout. Remainder cents go on the first installment so th...
High-Level Design
Two pure functions over a list so they are trivial to test. The invariant I would assert in tests: original total = paid installments + remaining unpaid installments + refund absorbed by the schedule,...