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
November 29, 20260
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
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
- 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 ProblemsSample 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...