Smallest Daily Capacity to Replay Log Batches Within D Days
Last updated: November 29, 2026
Quick Overview
A ByteDance data platform must replay ordered log batches of given sizes into a warehouse over at most D days, processing a contiguous prefix of remaining batches each day without splitting any batch; return the smallest daily capacity that works.
ByteDance
November 29, 20260
0
0 solved
A ByteDance data platform must replay ordered log batches of given sizes into a warehouse over at most D days, processing a contiguous prefix of remaining batches each day without splitting any batch; return the smallest daily capacity that works.
Backfills on ByteDance's offline data platform have to finish within a window while respecting batch order, and this binary search on the answer pattern appears often in their screens. The interviewer checks that you spot the monotonic feasibility check and pick the right search bounds.
What the Interviewer Expects
- Recognize feasibility is monotonic in capacity
- Set lo = max batch and hi = total size
- Write a greedy O(n) feasibility check
- Binary search for the first feasible capacity
- State O(n log(sum)) time
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
- Batches can be reordered: does the problem get easier or harder?
- Each day has a different capacity multiplier: adapt the check.
- Return the actual day boundaries.
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: a list of positive batch sizes in required order and D >= 1. Each day takes a contiguous run of batches whose total is at most capacity. Output: the minimum integer capacity so all batches fini...
High-Level Design
Any capacity below the largest batch is infeasible, and the total size finishes in one day, so the answer is in [max, sum]. If capacity c works, any larger capacity also works, so binary search on c. ...