Size a Hot Wallet Given a Limited Number of Refills
Last updated: November 29, 2026
Quick Overview
Given daily withdrawal totals in order, a hot wallet that starts full and can be topped up to its capacity at the start of at most k later days, find the smallest capacity that never runs dry.
Coinbase
November 29, 20260
0
0 solved
Given daily withdrawal totals in order, a hot wallet that starts full and can be topped up to its capacity at the start of at most k later days, find the smallest capacity that never runs dry.
Coinbase keeps most customer crypto in cold storage and only a small float in hot wallets, and every refill from cold storage is a slow, carefully controlled operation. The interviewer is looking for binary search on the answer with a greedy feasibility check and a clean argument for why the check is monotonic.
What the Interviewer Expects
- Reframe as partitioning days into at most k + 1 contiguous groups
- Write a greedy check that counts fills needed for a capacity
- Argue monotonicity: a larger capacity never needs more fills
- Bound the search between the largest day and the total
- Give O(n log S) complexity
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
- How would you also return which days to refill on?
- What if refills take a day to arrive, so you must request them one day ahead?
- How would you handle deposits that partially offset withdrawals each day?
- How do you pick capacity when demand is a forecast with uncertainty?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: non-negative integer demands per day and refills = k. The wallet starts at capacity C; at the start of a day you may top it up to C, at most k times. Output: minimum C such that every day's...
High-Level Design
Each fill serves a contiguous run of days whose total is at most C, so the question is the minimum largest group sum when splitting into at most k + 1 contiguous groups. For a fixed C, greedily extend...