Allocate a Card Payment Across Balances With Different APRs

Last updated: November 29, 2026

Quick Overview

A credit card account has several balance segments (purchases, a promotional balance transfer, a cash advance), each with an APR, a balance and a minimum due. Allocate a customer's payment by covering minimums first and then applying the excess to the highest-APR balance first.

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

0

0

0 solved


A credit card account has several balance segments (purchases, a promotional balance transfer, a cash advance), each with an APR, a balance and a minimum due. Allocate a customer's payment by covering minimums first and then applying the excess to the highest-APR balance first.

US card rules require that payment above the minimum be applied to the highest-rate balance first, and Capital One's servicing systems implement allocations like this for every payment. The interviewer checks a clean two-phase greedy, the exchange argument for why highest APR first minimizes interest, and careful handling of short payments.

What the Interviewer Expects
  • Separate the minimum phase from the excess phase
  • Apply excess in descending APR order
  • Never apply more than a segment's remaining balance
  • Handle payments smaller than the total minimum due
  • Justify the greedy choice with an exchange argument
Key Topics to Cover
Greedy algorithms
Exchange argument
Sorting
Financial rules
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
  • Prove that highest APR first minimizes next month's interest for a fixed excess amount.
  • How would a deferred-interest promotion that ends in two months change the best allocation?
  • How would you handle an overpayment that exceeds the total balance?
  • How would you test this allocation logic for regulatory compliance?
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
  • Each segment: name, balance, APR and minimum, all money in cents.
  • Phase 1: pay each minimum, capped at that segment's balance. If the payment cannot cover all minimums, apply it to the lowest-APR ...
High-Level Design

Two sorted passes. The excess phase is a greedy: each dollar removed from a balance with rate r saves r per period, so given a fixed amount to place, putting it on the largest r saves the most. Exchan...


Submit Your Answer
Markdown supported