Hash Maps interview problems
In practical interviews the hash map is rarely the puzzle. It is the data structure you reach for to group, count, index or join records, and the question is whether you reach for the right flavour. dict keeps insertion order, collections.defaultdict(list) removes the "is the key there yet" branch when grouping, collections.Counter gives you most_common(k) and arithmetic on counts, and dict.setdefault works when you only need one default. Tuples and frozen dataclasses make good composite keys. Lists and dicts can't be keys at all.
Common mistakes are mutating a dict while iterating over it, using a mutable default argument as a cache, keying on a value you haven't normalised (case, whitespace, trailing slashes), and keeping a list of records when running aggregates would do. A strong answer states what the key is and what the value holds before writing the loop, uses O(1) lookups instead of scanning a list inside a loop, and knows when a dict alone is not enough. If the follow-up needs ordering by recency or by value, say so and pair the dict with OrderedDict or a heap.
1 open problem
- 01Inference Log Summaryeasy
Parse pipe-delimited inference logs, skip malformed lines, and report request counts, successes and average latency per model.
6 locked
These open in order of demand. Open one and press I want this one to ask for it.
- 04Reassemble Streamed Tokens Lockedeasy
Rebuild each request's output from interleaved, out-of-order and duplicated token events keyed by request id and sequence number.
- 07Inference Request Queue Lockedmedium
Design a FIFO request queue with a status lifecycle: submit, start, complete and cancel, with O(1) operations and lazy removal.
- 28Per-Key Concurrency Limiter Lockedmedium
Limit how many async jobs run at once for each key, keep keys independent, and forget idle keys so memory stays bounded.
- 46Disk-Backed LRU Artifact Cache Lockedmedium
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.
- 48API Key Usage Tracker Lockedmedium
Enforce a per-API-key sliding-window quota on both request count and tokens, rejecting requests that do not fit, with memory bounded by the window.
- 50Streaming Response Aggregator Lockedmedium
Assemble interleaved token, done and error events into complete responses with a lazy generator that keeps only in-flight requests in memory.