~/problems
Problems
Basics first, then the classics, then company-style assessments. Every problem has tests you run right here; multi-level ones unlock as you go. See the roadmap.
Heap scheduling (deadlines, leases)
Min-heap of deadlines, lazy deletion, event simulation.
Notes
Recognise it when: "earliest deadline / soonest expiry first", leases, timers, event simulation, top-k, scheduling by time.
heapq.heappush(h, (deadline, seq, item)) # seq breaks ties, avoids comparing items
while h and h[0][0] <= now:
_, _, item = heapq.heappop(h)
if still_valid(item): handle(item) # lazy deletion
- Lazy deletion: don't remove items from the middle of the heap. Mark them stale (a version or token) and skip them when they surface.
- Keep running totals next to the heap so you never sum the whole heap.
- A max-heap is a heap of negated keys.
8 problems
Interview roadmap
Heaps Top-k, merging streams, scheduling by time.
Heap scheduling (deadlines, leases) guide
- Basics: hand each job to the earliest-free server basics py · c++ · java easy
- Laundromat with impatient customers py · c++ · java easy
- Task Scheduler py · c++ · java medium
- Single-Threaded CPU py · c++ · java medium
- GPU credit ledger 3 levels OpenAI py · c++ · java hard
- Webhook delivery with retries 3 levels OpenAI medium
- Task processor with dependencies and deadlines 3 levels Scale AI medium
- Meeting Rooms III py · c++ · java hard