GPU credit ledger
A backend candidate reports a coding round on managing GPU credits.
Read source report ↗Original exercise & acceptance cases
Original variant: implement grant(id, amount, start, end), consume(amount, time), and balance(time). Use [start,end), consume earliest-expiring credits first, reject insufficient funds atomically, and accept events in chronological order.
Acceptance cases: Grant A=10 on [0,10), B=5 on [3,6). Consume 7 at t=4: B becomes 0, A becomes 8. Balance at t=6 is 8; at t=10 is 0. Test duplicate IDs and rejected withdrawals.
Solution outline & self-assessment
Start with a sorted grant list and a reference implementation. State interval semantics before choosing a heap. A rejected debit must leave every grant unchanged. Extension: out-of-order events require explicit replay or versioning semantics.
Score 0–2 on each: clear assumptions, correct reasoning, edge-case coverage, trade-off discussion. Total /8 is a personal study rubric, not a company hiring score.