Minimize Wire Fees When Batching Daily Loan Disbursements

Last updated: November 29, 2026

Quick Overview

Loan disbursements for a day arrive in a fixed order. You may group them into at most k contiguous batches, where each batch costs a fixed fee plus its length times its largest disbursement (a risk-weighted handling charge); return the minimum total cost.

Upstart
Coding & Algorithms
Software Engineer
Upstart
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Loan disbursements for a day arrive in a fixed order. You may group them into at most k contiguous batches, where each batch costs a fixed fee plus its length times its largest disbursement (a risk-weighted handling charge); return the minimum total cost.

Upstart funds loans through bank and credit union partners, and treasury operations trade off fewer wires against concentration risk. This onsite problem checks whether you can define a partition DP with a batch-count dimension and keep the inner loop efficient by tracking the running maximum.

What the Interviewer Expects
  • Define dp[j][i] for the first i items with exactly j batches
  • Iterate the last batch's start while tracking its running maximum
  • Handle the at-most-k requirement
  • Validate against a brute force on small inputs
  • Discuss O(k n^2) complexity and possible speedups
Key Topics to Cover
partition DP
2D dynamic programming
running maximum
optimization
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
  • Drop the k limit. How does the DP simplify?
  • Can you reduce memory to two rows?
  • If cost were fee plus the batch sum, what would the optimal structure look like?
  • How would you speed this up for n around 10^5?
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: a list of positive amounts in arrival order, integer k >= 1, non-negative fee. Batches must be contiguous and cover every disbursement. Cost per batch is fee + len * max. Return the minimum ...

High-Level Design

Let dp[j][i] be the cheapest way to cover the first i disbursements with exactly j batches. The last batch is amounts[s:i] for some s, so `dp[j][i] = min over s of dp[j-1][s] + fee + (i - s) * max...


Submit Your Answer
Markdown supported

Related Questions