Minimum Cost of Reserved GPU Capacity Across Scheduled Days

Last updated: November 29, 2026

Quick Overview

A team knows the days on which it will need reserved GPU capacity. Reservation plans of various lengths have fixed prices, and a plan bought on day d covers d through d + length - 1; return the minimum total spend that covers every needed day.

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

0

0

0 solved


A team knows the days on which it will need reserved GPU capacity. Reservation plans of various lengths have fixed prices, and a plan bought on day d covers d through d + length - 1; return the minimum total spend that covers every needed day.

Compute is OpenAI's largest cost, and choosing between short and long reservations for bursty experiment schedules is a real decision. The question is 1D DP over the sorted list of needed days; interviewers check the state definition, why starting a plan on a needed day is enough, and how to avoid recomputing coverage with a pointer.

What the Interviewer Expects
  • Define dp over indices of needed days rather than every calendar day
  • Argue that an optimal solution starts each plan on a needed day
  • Find the first uncovered day per plan with a forward scan or binary search
  • Handle arbitrary plan lists, not only 1, 7 and 30 days
  • State complexity in terms of days and plans
Key Topics to Cover
1D dynamic programming
interval covering
binary search
cost optimization
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
  • Prices change by start date: how does the DP change?
  • Plans can be shared by two teams with different schedules: what is the new state?
  • Need is fractional (some days need 8 GPUs, others 64): how would you model it?
  • Return which plans to buy, not just the cost.
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: sorted distinct days, and plans as (length, price).
  • Every listed day must be covered by at least one plan.
  • Output: minimal total price; no days means 0....
High-Level Design

Let dp[i] be the cheapest way to cover days[i:]. The day days[i] must be covered by some plan, and moving that plan's start later until it begins exactly on days[i] never uncovers an earlier n...


Submit Your Answer
Markdown supported