Split Daily Order Flow Into K Sessions Minimizing Peak Load
Last updated: November 29, 2026
Quick Overview
A day's order flow is a sequence of per-minute volumes that must be processed in order by K consecutive operator or server sessions. Split the sequence into at most K contiguous sessions so the busiest session's total volume is as small as possible.
DRW
November 29, 20260
0
0 solved
A day's order flow is a sequence of per-minute volumes that must be processed in order by K consecutive operator or server sessions. Split the sequence into at most K contiguous sessions so the busiest session's total volume is as small as possible.
Capacity planning for order entry gateways and support coverage at a trading firm reduces to partitioning a sequence. DRW interviewers like binary search on the answer because it rewards spotting monotonicity, and they will ask you to prove the feasibility check is greedy optimal.
What the Interviewer Expects
- Identifies the answer range from max element to total sum
- Writes a greedy feasibility check counting sessions for a cap
- Argues monotonicity: a larger cap never needs more sessions
- Binary searches to the minimal feasible cap
- Reconstructs one valid split
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
- Solve it with DP and compare complexity.
- Volumes are floats: how do you terminate the binary search?
- Sessions have different speeds: what changes?
- What if sessions may be non contiguous?
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 volumes and k >= 1. Output: minimal peak and one split achieving it using at most k sessions....
High-Level Design
For a candidate cap C, greedily pack minutes into the current session until the next would exceed C, then start a new one. Greedy is optimal for feasibility: closing a session early never lets later s...