Earliest Start Slot For A Gang-Scheduled Training Job

Last updated: November 29, 2026

Quick Overview

Given a cluster's GPU capacity and a list of running jobs and future reservations as (start, end, gpus) intervals, find the earliest time a new job needing g GPUs continuously for duration d can start.

Crusoe
Coding & Algorithms
Software Engineer
Crusoe
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Given a cluster's GPU capacity and a list of running jobs and future reservations as (start, end, gpus) intervals, find the earliest time a new job needing g GPUs continuously for duration d can start.

Crusoe clusters run gang-scheduled training jobs that need all their GPUs at once for hours, alongside reservations booked ahead by other customers, so a scheduler must answer when a new job can fit. The interviewer checks that you reduce the problem to a capacity step function and find a window whose minimum free capacity meets the demand efficiently.

What the Interviewer Expects
  • Builds free capacity as a step function from interval deltas
  • Shows the earliest feasible start is either now or a segment boundary
  • Uses a sliding window minimum (monotonic deque) for O(n log n) overall
  • Handles intervals that started in the past and an open-ended final segment
  • Explains the simpler case where only running jobs exist and free capacity only grows
Key Topics to Cover
Step functions
Sliding window minimum
Monotonic deque
Gang scheduling
Reservations
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
  • Now return the start time and also book the job so later queries see it. Which structure supports both quickly?
  • Jobs can be placed on one of several clusters with different capacities. How do you choose?
  • Allow a job to start with fewer GPUs and grow (elastic training). How does the question change?
  • How would backfilling smaller jobs into gaps interact with this?
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: capacity, intervals (start, end, gpus) on [start, end), demand g, duration d > 0, current time now. Output: earliest t >= now with free GPUs at least g throughout [t, t+d), or...

High-Level Design

Free capacity changes only at interval endpoints, so it is a step function over segments. If a start time t inside a segment works, the start of that segment also works unless the previous segment is ...


Submit Your Answer
Markdown supported

Related Questions