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
Coding & Algorithms
Software Engineer
MathWorks
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

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
binary search on answer
greedy feasibility
partitioning
load balancing
parallel simulation
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported

Related Questions