Peak Concurrent Device Memory From Allocation Lifetimes

Last updated: November 29, 2026

Quick Overview

Given device allocations as (start_time, end_time, bytes) live on the half-open interval [start, end), return the peak total bytes live at any moment and the earliest time that peak is reached.

NVIDIA
Coding & Algorithms
Software Engineer
NVIDIA
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given device allocations as (start_time, end_time, bytes) live on the half-open interval [start, end), return the peak total bytes live at any moment and the earliest time that peak is reached.

A common onsite question for NVIDIA teams building CUDA memory allocators, TensorRT engine builders and framework memory planners, where knowing peak memory before running a graph decides whether a model fits on a GPU. The interviewer checks sweep line reasoning and careful tie handling at equal timestamps.

What the Interviewer Expects
  • Converts each allocation into +bytes and -bytes events
  • Sorts so that frees at time t are applied before allocations at time t, matching half-open intervals
  • Tracks the running total and records peak and its time
  • Explains O(n log n) cost and filters malformed intervals
  • Connects the result to activation memory planning or buffer reuse
Key Topics to Cover
sweep line
intervals
sorting
event processing
memory 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 also return which allocations are live at the peak?
  • If you may reorder independent ops, how could you lower the peak?
  • How would you compute the minimum pool size needed if blocks cannot move (fragmentation)?
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

Each allocation is live on [start, end). If one buffer frees at t=10 and another allocates at t=10, they do not overlap. Return (peak_bytes, time). Ignore zero-length or zero-byte entries. Ask whe...

High-Level Design

Sweep line. Emit (start, +bytes) and (end, -bytes) per allocation, sort by time, and walk the events with a running total. Sorting tuples puts negative deltas before positive ones at the same time...


Submit Your Answer
Markdown supported

Related Questions