Reported September 2026
OpenAIheap priority queue

GPU Credit Ledger with a Negative-Balance Failure State

Reported by candidates from OpenAI's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live OpenAI OA. Under 2s to a working solution.
Founder's read

The detail that trips people in this OpenAI GPU credit ledger is the failure state. One oversized SUBTRACT and every later BALANCE returns NONE, no matter what you add afterward. OpenAI candidates reported this one in September 2026, and it reads like simulation with a priority queue hiding underneath. You process ADD, SUBTRACT and BALANCE strings in order, track grants by expiration, and stop trusting the ledger the moment it goes negative. It's a short spec with a few sharp edges. If you blank mid-assessment, StealthCoder runs invisibly on your desktop and gives you a working solution while you recover.

The problem

Process a time-aware GPU credit ledger from the operations in operations.
Supported operations
ADD grantId amount start expire: add a grant with positive credits. It is active when start <= timestamp < expire.
SUBTRACT amount timestamp: spend active credits, consuming grants with the earliest expiration first. Grants with equal expiration are consumed in insertion order.
BALANCE timestamp: append the active remaining balance as a decimal string.
Operation timestamps are nondecreasing. If a subtraction exceeds the active balance, the ledger enters a permanent negative-balance failure state. That subtraction does not need a returned value, and every later BALANCE appends NONE. Later additions or subtractions cannot recover the failed ledger.

Function
processGpuCreditsUntilNegative(operations: String[]) → String[]

Examples
Example 1
operations = ["ADD a 4 0 10","ADD b 3 0 5","SUBTRACT 5 1","BALANCE 1","BALANCE 6"]
return = ["2","2"]
The subtraction consumes all three credits from b and two from a. The two remaining credits in a are active at both queried timestamps.
Example 2
operations = ["ADD a 2 0 10","SUBTRACT 3 1","BALANCE 1","ADD b 5 2 20","BALANCE 2"]
return = ["NONE","NONE"]
The subtraction exceeds the two active credits and permanently fails the ledger, so both later balance queries return NONE.

Constraints
1 <= operations.length <= 100000.
Grant identifiers are nonempty and unique.
1 <= amount <= 10^9 and 0 <= start < expire <= 10^9.
Operation timestamps are nondecreasing.
All valid balances fit in a signed 64-bit integer.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is a min-heap keyed on (expire, insertion index). Timestamps are nondecreasing, so you never go backward. Grants with start in the future sit in a pending structure until their start time arrives. On each operation, move pending grants whose start has been reached into the heap, and pop grants whose expire has passed. Keep a running active total so BALANCE is O(1) after cleanup. For SUBTRACT, pull from the heap top, partially consuming a grant and pushing back the remainder or editing it in place. If the total active credits are less than the amount, set a failed flag and return NONE for every later BALANCE. The classic pitfall is checking the failure after mutating the heap, or forgetting that later ADDs can't revive the ledger. Also watch the boundary: active means start <= t < expire. Use 64-bit sums. StealthCoder is the hedge if the heap bookkeeping slips live.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill GPU Credit Ledger with a Negative-Balance Failure State cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass OpenAI's OA.

OpenAI reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

GPU Credit Ledger with a Negative-Balance Failure State FAQ

What's the core trick in the OpenAI GPU credit ledger problem?+

Use a min-heap ordered by expiration, then insertion order, to decide which grant to spend first. Keep a separate structure for grants that haven't started yet. Track the active total so BALANCE doesn't rescan everything. The failure flag is just a boolean checked on every BALANCE.

How hard is this problem really?+

Medium. The algorithm is a standard heap simulation, but the spec has many small rules: start and expire boundaries, tie-breaking by insertion order, partial consumption, and permanent failure. Most lost points come from boundary mistakes, not from the data structure choice.

When should I check for the negative-balance failure?+

Before you consume anything on a SUBTRACT. Clean out expired grants, activate pending ones, then compare the amount to the active total. If it's larger, set the failed flag and skip the mutation. After that, ignore ADD and SUBTRACT and answer NONE for BALANCE.

How do I handle grants that start in the future?+

Store them in a pending list sorted by start, or a second heap keyed on start. Because timestamps never decrease, you can move grants into the active heap once their start is at or before the current timestamp. Never count them in the balance before that.

How do I prepare for this in 48 hours?+

Write the solution once from scratch with a heap and a pending queue. Then test the examples plus edge cases: a grant expiring exactly at the query time, equal expirations, and an ADD after failure. Know that the whole thing is O(n log n) for 100000 operations.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with OpenAI.

OA at OpenAI?
Invisible during screen share
Get it