Practical Python interview practice

The interview questions LeetCode skips.

Rate limiters, retries with backoff, worker pools, batching, streaming parsers and log crunching. The systems-flavoured Python you get asked to write in a practical round, with a real test suite. CPython runs in your browser through WebAssembly. No sign-up, no server, nothing leaves your machine.

Problems

50 problems
No.ProblemDifficultyTopicsTimeStatus
01 Inference Log Summary

Parse pipe-delimited inference logs, skip malformed lines, and report request counts, successes and average latency per model.

easy 20m
02 Normalize Inference Requests

Parse raw JSON inference requests, validate required and optional fields, fill defaults and drop anything malformed.

easy 20m
03 Parse an SSE Token Stream

Reassemble a streamed LLM response from Server-Sent Events chunks that can split anywhere, handling CRLF, junk payloads and [DONE].

medium 25m
04 Reassemble Streamed Tokens

Rebuild each request's output from interleaved, out-of-order and duplicated token events keyed by request id and sequence number.

easy 20m
05 Priority Batch Scheduler

Pick which inference requests go into one GPU batch: highest priority first, FIFO on ties, skip what does not fit, never exceed the token budget.

medium 25m
06 Sliding Window Rate Limiter

Build a per-user sliding window log rate limiter that allows at most N requests in any window of W seconds.

medium 25m
07 Inference Request Queue

Design a FIFO request queue with a status lifecycle: submit, start, complete and cancel, with O(1) operations and lazy removal.

medium 25m
08 Retry Scheduler with Exponential Backoff

Build a request scheduler that retries failures with exponential backoff, orders work by ready time and tracks a five-state lifecycle.

hard 40m
09 Concurrent Inference Batch

Run a batch of async inference calls with a concurrency cap, isolate per-request failures and return results in input order.

medium 25m
10 Async Inference with Retries and Timeouts

Run async inference calls under a concurrency cap with a per-attempt timeout, bounded retries, attempt counts and correct cancellation.

hard 35m
11 Dynamic Request Batching

Group arriving inference requests into batches that close when full or when a wait deadline passes, using an asyncio producer and consumer.

hard 40m
12 Inference Worker Pool

Run inference requests through a fixed pool of asyncio workers sharing one queue, isolate failures, and return results in input order.

medium 25m
13 Cancellable Inference Manager

Build a manager that runs inference requests in the background with a concurrency cap, supports cancelling them, and reports each final result.

medium 35m
14 Fair Async Token Bucket

Implement an asyncio token bucket rate limiter that serves waiters in strict FIFO order and handles cancelled waiters without leaking tokens.

hard 40m
15 Concurrent Web Crawler

Crawl one hostname breadth-first with asyncio, a depth limit and a concurrency cap, fetching each URL once and returning URLs in BFS order.

medium 30m
16 Async Circuit Breaker

Implement an asyncio circuit breaker with closed, open and half-open states, a single recovery probe, and protection against stale in-flight calls.

hard 40m
17 GPU Memory Scheduler

Admit async jobs onto a GPU with fixed memory in strict FIFO order, so large jobs never starve, and survive cancelled waiters without leaking memory.

hard 40m
18 Streaming Inference Limiter

Wrap token-streaming backends in an async generator that caps concurrent streams, starts lazily, and frees its slot on every exit path.

medium 30m
19 Bounded Worker Pool with Graceful Shutdown

Build an asyncio worker pool with a bounded job queue, backpressure on submit, and a graceful shutdown that drains accepted jobs and rejects new ones.

hard 40m
20 Dynamic Request Batcher

Group concurrent inference requests into batches that flush when full or when the oldest request has waited long enough, with cancellation and drain.

hard 45m
21 Async TTL Cache with Request Coalescing

Build an asyncio cache whose entries expire after a TTL, where concurrent misses for the same key share one fetch that survives caller cancellation.

medium 30m
22 Async Retry with Exponential Backoff

Retry a failing coroutine with capped exponential backoff, re-raise the last error, and never swallow cancellation.

medium 20m
23 Async Worker Pool with Timeouts

Cap how many async jobs run at once and time out each job from when it starts, not from when it was queued.

medium 20m
24 Async Sliding Window Rate Limiter

Admit at most N requests in any rolling window of T seconds, making callers await until a slot opens.

medium 25m
25 Async Request Deduplicator

Collapse concurrent fetches for the same key into one shared call, with per-caller timeouts that never cancel the shared work.

hard 35m
26 Async Priority Job Scheduler

Run submitted async jobs on N workers in priority order, FIFO within a priority, with cancellation and a draining shutdown.

hard 40m
27 Async Inference Batcher

Group single inference requests into batches by size or wait time, with per-request timeouts, cancellation and a draining shutdown.

hard 45m
28 Per-Key Concurrency Limiter

Limit how many async jobs run at once for each key, keep keys independent, and forget idle keys so memory stays bounded.

medium 25m
29 Round-Robin Load Balancer

Route async requests to model replicas in round-robin order, skipping replicas marked unhealthy and failing fast when none are left.

easy 20m
30 Least-Loaded Replica Scheduler

Send each async request to the healthy replica with the fewest in-flight requests, wait when all are full, and react to health changes.

hard 40m
31 Chunked File Copy with Bounded Memory

Copy a file of any size in fixed-size chunks so memory stays flat, and refuse inputs that would destroy data.

easy 15m
32 File Chunk Iterator

Write a lazy generator that reads a byte range of a file in fixed-size chunks without ever loading the whole file into memory.

easy 15m
33 Streaming File Checksum

Compute and verify a SHA-256 checksum of a large file by hashing it in chunks, rejecting malformed expected digests.

easy 15m
34 Split and Merge Files

Split a large file into fixed-size numbered parts and merge parts back together, streaming in chunks with bounded memory.

medium 25m
35 Atomic File Copy

Copy a file through a temp file and atomic rename so readers never see a partial destination, with progress callbacks and cleanup on failure.

medium 25m
36 Delimited Stream Parser

Turn an iterator of arbitrary byte chunks into delimited messages, handling messages and multi-byte delimiters split across chunks.

medium 20m
37 Stream Rechunker

Regroup a stream of arbitrarily sized byte chunks into fixed-size chunks, lazily and with memory bounded by the chunk size.

easy 15m
38 Stream Until Stop Sequence

Forward streamed LLM text until a stop sequence appears, holding back only a possible partial match even when it spans chunks.

medium 30m
39 Streaming JSONL Parser

Parse JSON Lines from arbitrary byte chunks into records, handling split lines and UTF-8, with a strict mode and a skip-invalid mode.

medium 20m
40 Length-Prefixed Message Parser

Decode a stream of 4-byte big-endian length-prefixed messages from arbitrary chunks, rejecting oversized and truncated frames.

medium 25m
41 Atomic Async Download

Save an async byte stream to disk atomically, enforcing an expected size and cleaning up on errors, callback failures and cancellation.

hard 30m
42 Chunked Upload with Retries

Upload a large file in fixed-size chunks through an async send function, retrying each chunk independently and never loading the whole file.

medium 25m
43 Merge Async Streams

Merge several async generators into one stream that yields items as soon as any source produces them, with bounded buffering and clean shutdown.

hard 35m
44 Resumable Download

Resume an interrupted file download from the bytes already on disk, append streamed chunks, report progress, and reject wrong-sized data.

medium 25m
45 Stream Idle and Total Timeout

Wrap an async token stream so it fails when the gap between items is too long or the whole stream runs past a deadline, closing the source.

medium 25m
46 Disk-Backed LRU Artifact Cache

Build a byte-budgeted LRU cache that stores model artifacts as files on disk, evicting least recently used entries and keeping only metadata in memory.

medium 30m
47 Token Budget Batching

Greedily group inference requests into ordered batches capped by both a maximum request count and a maximum total token count.

easy 15m
48 Sliding Window Model Metrics

Track per-model request count, error rate, average latency and tokens over a sliding time window, with O(1) amortized updates and bounded memory.

medium 25m
49 Reference-Counted Model Manager

Load each model once for many concurrent users, unload it when the last user releases it, and handle load failures and acquires during unload.

hard 40m
50 Streaming Response Aggregator

Assemble interleaved token, done and error events into complete responses with a lazy generator that keeps only in-flight requests in memory.

medium 20m