OpenAI

Verified interview challenge

GPU Credit 2

Keep a GPU credit ledger accurate as grants expire and spending reduces the balance.

Unlock with Full Access

The challenge

Build a ledger that tracks credit grants, deductions and the remaining balance. In this variant, spending permanently consumes credit, so later queries must reflect what has already been used. The complete problem specifies how deductions and expiration interact.

What you'll practise

  • Persistent deductions

    Keep balances consistent across a sequence of spending operations.

  • Expiring grants

    Account for credits that become unavailable as time advances.

  • Efficient queries

    Choose data structures that handle a large number of ledger operations.

Your coding workspacePreview
solution.pyPython 3.13
class GPUCredit:
    def __init__(self) -> None:
        pass

    # Your implementation goes here
Test cases

Run your code to see results.

Full instructions, starter code and test cases included with Full Access.