Split Batch Simulation Jobs Across Workers to Minimize Makespan
Last updated: November 29, 2026
Quick Overview
Given simulation run durations in a fixed order and a number of workers, split the list into at most that many contiguous chunks, one per worker, so the longest chunk total is as small as possible; return that makespan and one valid split.
MathWorks
November 29, 20260
0
0 solved
Given simulation run durations in a fixed order and a number of workers, split the list into at most that many contiguous chunks, one per worker, so the longest chunk total is as small as possible; return that makespan and one valid split.
Parallel Computing Toolbox and Simulink's parsim distribute parameter sweeps across workers, and keeping runs contiguous preserves cache locality and log ordering. The interviewer checks binary search on the answer with a greedy feasibility check and a clean proof of monotonicity.
What the Interviewer Expects
- Identifies the answer range [max(durations), sum(durations)]
- Writes a greedy check that counts chunks needed for a given cap
- Argues monotonicity: if a cap is feasible, any larger cap is feasible
- Uses lower-bound binary search and rebuilds the split at the final cap
- States O(n log S) 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
- If runs need not stay contiguous, what changes? Is the problem still polynomial?
- How would you handle workers with different speeds?
- Durations are only estimates. How would you add dynamic load balancing on top of this static plan?
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: list of positive integer durations in run order, integer workers >= 1. Output: (makespan, groups) where groups is a list of at most workers contiguous chunks whose largest sum equals the ...
High-Level Design
The best makespan lies between the longest single run and the total. For a candidate cap, a greedy pass packs runs into the current chunk until the next run would exceed the cap, then starts a new chu...