Compute Billable GPU Hours From Overlapping Reservation Intervals

Last updated: November 29, 2026

Quick Overview

Given a list of GPU node reservations as (node_id, start_hour, end_hour) with end exclusive, return the total billable hours per node, where overlapping or touching reservations on the same node are billed only once.

Nebius
Coding & Algorithms
Software Engineer
Nebius
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given a list of GPU node reservations as (node_id, start_hour, end_hour) with end exclusive, return the total billable hours per node, where overlapping or touching reservations on the same node are billed only once.

A warm-up in the style of a Nebius phone screen for cloud platform engineers, framed around the hourly GPU billing that AI Cloud customers see. The interviewer checks that you clarify interval semantics, group by key, and write clean merge logic without off-by-one errors.

What the Interviewer Expects
  • Clarifies whether end is inclusive or exclusive and whether touching intervals merge
  • Groups reservations by node before merging
  • Sorts by start and merges in one linear pass
  • Ignores or rejects zero and negative length intervals explicitly
  • States O(n log n) time and O(n) space
Key Topics to Cover
interval merging
sorting
hash maps
billing semantics
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 bill per second instead of per hour, and does anything change?
  • Reservations stream in continuously; how do you maintain totals incrementally?
  • How would you split the total by billing month when intervals cross a month boundary?
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: tuples (node_id, start, end) with end exclusive. Output: {node_id: hours}. Overlapping reservations on one node (two teams accidentally booking the same node, or a retry that double-books...

High-Level Design

Bucket intervals by node with a dict of lists. For each node, sort by start, sweep keeping a current merged interval, and add its length to the total whenever the next interval starts after the curren...


Submit Your Answer
Markdown supported

Related Questions