Deduplication interview problems

Deduplication questions ask you to process each logical item once even when it arrives more than once. In the simple version you remove duplicates while keeping first-seen order, which dict.fromkeys(items) does in one line. Harder versions dedupe events by an idempotency key within a time window, collapse concurrent identical requests into one in-flight call, or find duplicate files by content hash. The structures are a set or dict of seen keys, a deque or heap to expire old keys, and a normalisation function that defines what counts as the same item.

The common mistakes are an unbounded seen-set that grows for the life of the process, deduping on the raw value when the spec says case or whitespace doesn't matter, and marking a key as seen before the work succeeds so a failed attempt can never be retried. A strong answer asks what identity means for this data, bounds memory with a window or TTL, and decides whether "seen" means received or completed. When memory is tight, it brings up a Bloom filter and its false positive trade.

2 open problems

  1. 21Async TTL Cache with Request Coalescingmedium

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

  2. 25Async Request Deduplicatorhard

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

1 locked

These open in order of demand. Open one and press I want this one to ask for it.

  1. 15Concurrent Web Crawler Lockedmedium

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