Peak GPU Demand Across Overlapping Simulation Jobs

Last updated: November 29, 2026

Quick Overview

Each simulation job has a start time, an end time (exclusive) and a number of GPUs it holds. Return the peak number of GPUs in use at once and the earliest time that peak begins.

Applied Intuition
Coding & Algorithms
Software Engineer
Applied Intuition
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Each simulation job has a start time, an end time (exclusive) and a number of GPUs it holds. Return the peak number of GPUs in use at once and the earliest time that peak begins.

Applied Intuition runs large batches of simulation on shared GPU clusters, so capacity questions come up naturally. Interviewers look for the sweep-line pattern and careful ordering of events at the same timestamp.

What the Interviewer Expects
  • Turn each job into a +g event at start and a -g event at end
  • Sort events and process releases before acquisitions at equal times
  • Track the running total and the first time the maximum is reached
  • Ignore zero or negative length jobs
  • Explain why half-open intervals matter
Key Topics to Cover
sweep line
event sorting
intervals
capacity planning
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
  • How would you return the full usage timeline for plotting?
  • How would you answer many queries of usage at time t?
  • What if jobs arrive online and you need the current peak continuously?
  • How do you find the minimum cluster size so no job ever waits?
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

Jobs are (start, end, gpus) with half-open intervals, so a job ending at 10 frees its GPUs before one starting at 10 takes them. Return (peak, time_of_peak); (0, None) when there are no jobs....

High-Level Design

Create 2n events. Sorting by (time, delta) puts negative deltas first at a tie, which encodes the half-open rule. Walk events in order, keep the running sum and update the peak only when it strictly...


Submit Your Answer
Markdown supported

Related Questions