Typorithm · medium

Classic Problems

classic-designssystem-designurl-shortenernews-feedchat
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn Classic Problems

0%

Design Interview

The classic problems repeat: a URL shortener (hashing plus a key-value store), a news feed (fan-out on write vs on read), chat (WebSockets plus message queues), a rate limiter (token bucket), and typeahead/search (inverted index or trie). The real skill is recognizing reusable building blocks.

A URL shortener maps a long URL to a short key — generate the key by hashing or a counter, then store the mapping in a fast key-value store and redirect on lookup.

A news feed is the fan-out tradeoff: fan-out on write precomputes each follower's timeline when someone posts (fast reads, expensive writes for popular accounts), while fan-out on read assembles the feed at request time (cheap writes, slower reads). Chat layers a live WebSocket connection over a message queue that handles delivery and offline users.

A rate limiter typically uses a token bucket to smooth bursts, and typeahead/search relies on an inverted index or a trie. Recognizing these reusable building blocks — and naming the right one quickly — is what the interview is really testing.

01

URL shortener: hash plus key-value store.

02

News feed: fan-out on write vs on read.

03

Chat: WebSockets plus a message queue.

problems:
  url_shortener: hash-and-kv-store
  news_feed: fanout-on-write
  chat: websockets-and-queue
  rate_limiter: token-bucket
  search: inverted-index

Read the implementation

Connect each part of the code to the concept before you type.

1. URL shortener

Hash a long URL to a short key and store the mapping in a key-value store.

url_shortener: hash-and-kv-store

2. News feed

Fan-out on write precomputes each follower's feed at post time; fan-out on read assembles it at read time.

news_feed: fanout-on-write

3. Chat

WebSockets keep a live connection; a message queue handles delivery and offline buffering.

chat: websockets-and-queue

4. Rate limiter

A token bucket grants requests as tokens refill, smoothing bursts.

rate_limiter: token-bucket

5. Typeahead/search

An inverted index (or a trie for typeahead) maps terms to the documents that contain them.

search: inverted-index

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

Classic Problems: Lesson & Practice · Typorithm | ApplyDjinn