<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Arslan Ahmad</title>
    <description>The latest articles on DEV Community by Arslan Ahmad (@arslan_ah).</description>
    <link>https://dev.to/arslan_ah</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F34147%2F2974e0a5-f688-45b5-a4c9-5fa49c257854.jpg</url>
      <title>DEV Community: Arslan Ahmad</title>
      <link>https://dev.to/arslan_ah</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arslan_ah"/>
    <language>en</language>
    <item>
      <title>Grokking the System Design Interview: How to Design a Rate Limiter (Step by Step)</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Tue, 06 Oct 2026 08:09:16 +0000</pubDate>
      <link>https://dev.to/arslan_ah/grokking-the-system-design-interview-how-to-design-a-rate-limiter-step-by-step-5g25</link>
      <guid>https://dev.to/arslan_ah/grokking-the-system-design-interview-how-to-design-a-rate-limiter-step-by-step-5g25</guid>
      <description>&lt;p&gt;"Design a rate limiter."&lt;/p&gt;

&lt;p&gt;It sounds small. It is not.&lt;/p&gt;

&lt;p&gt;This question shows up at Stripe, Google, Amazon, Cloudflare, and almost every company that runs a public API. It is short enough to fit in 45 minutes. But it is deep enough to separate a junior answer from a senior one.&lt;/p&gt;

&lt;p&gt;In this post, I will walk through the problem the way we teach it in Grokking the System Design Interview. Step by step. Requirements first, then estimates, then algorithms, then architecture, then the hard parts.&lt;/p&gt;

&lt;p&gt;Let's go.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a Rate Limiter?
&lt;/h2&gt;

&lt;p&gt;A rate limiter controls how many requests a client can send in a given time window.&lt;/p&gt;

&lt;p&gt;If a user is allowed 100 requests per minute, request number 101 gets rejected. Usually with an HTTP &lt;code&gt;429 Too Many Requests&lt;/code&gt; response.&lt;/p&gt;

&lt;p&gt;Think of it like a nightclub bouncer with a clicker. The club holds 200 people. The bouncer counts everyone who walks in. When the counter hits 200, the next person waits outside. Nobody is being rude. The building just has a limit.&lt;/p&gt;

&lt;p&gt;Rate limiters exist for three main reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Protect your servers.&lt;/strong&gt; One buggy script or one bad actor should not take down the whole service.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Control costs.&lt;/strong&gt; If every request hits a paid third-party API, unlimited traffic means an unlimited bill.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep things fair.&lt;/strong&gt; One heavy user should not slow the system down for everyone else.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Clarify the Requirements
&lt;/h2&gt;

&lt;p&gt;Never start drawing boxes right away. Ask questions first. In a real interview, this is where you earn your first points.&lt;/p&gt;

&lt;p&gt;Here are the questions I would ask:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Client-side or server-side?&lt;/strong&gt; Server-side. Client-side limits are easy to bypass.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What do we limit by?&lt;/strong&gt; User ID, IP address, API key, or a mix. Let's support all of them through configurable rules.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What scale?&lt;/strong&gt; Think large. Millions of users, a few hundred thousand requests per second at peak.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Distributed?&lt;/strong&gt; Yes. Many API servers sit behind a load balancer. The limit must hold across all of them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What happens when a request is throttled?&lt;/strong&gt; Return &lt;code&gt;429&lt;/code&gt; with headers that tell the client when to retry.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hard or soft limit?&lt;/strong&gt; Mostly hard. A tiny overshoot during a race is acceptable if it keeps latency low.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;From those answers, we can write the requirements down.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Functional requirements&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Limit requests per client based on configurable rules (for example, 100 requests per minute per user).&lt;/li&gt;
&lt;li&gt;Return &lt;code&gt;429&lt;/code&gt; when a client exceeds the limit.&lt;/li&gt;
&lt;li&gt;Tell the client its remaining quota through response headers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Non-functional requirements&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Low latency.&lt;/strong&gt; The check sits on every request. It must add only a millisecond or two.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Highly available.&lt;/strong&gt; If the rate limiter breaks, the API should not break with it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Accurate enough.&lt;/strong&gt; Small errors are fine. Letting 10x the limit through is not.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalable.&lt;/strong&gt; Works across many servers and regions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 2: Back-of-the-Envelope Estimates
&lt;/h2&gt;

&lt;p&gt;Let's keep the math simple.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;10 million daily active users.&lt;/li&gt;
&lt;li&gt;Peak traffic of 200,000 requests per second.&lt;/li&gt;
&lt;li&gt;Each counter needs a key (about 50 bytes) plus a count and a timestamp (about 16 bytes). Call it roughly 100 bytes with overhead.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Memory for 10 million active counters:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;10,000,000 x 100 bytes = 1 GB&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That fits in memory on a single Redis node. But 200,000 checks per second, with a read and a write each, is better spread across a small Redis cluster. That also gives us replication for availability.&lt;/p&gt;

&lt;p&gt;The takeaway: &lt;strong&gt;storage is cheap here. Latency and coordination are the real problems.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Pick a Rate Limiting Algorithm
&lt;/h2&gt;

&lt;p&gt;This is the heart of the interview. There are five classic algorithms. You do not need all of them in detail, but you should know the trade-offs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgcw2l2j55go1y27dupdd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgcw2l2j55go1y27dupdd.png" alt="5 rate limiting algorithms compared: token bucket, leaky bucket, fixed window, sliding window log, sliding window counter" width="800" height="469"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Token Bucket
&lt;/h3&gt;

&lt;p&gt;A bucket holds tokens. Tokens refill at a fixed rate. Every request takes one token. No token, no entry.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bucket size = how big a burst you allow.&lt;/li&gt;
&lt;li&gt;Refill rate = your long-term average limit.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; Simple. Memory efficient. Allows short bursts, which matches real user behavior.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cons:&lt;/strong&gt; Two parameters to tune.&lt;/p&gt;

&lt;p&gt;This is what Amazon API Gateway and Stripe use. It is the safest default in an interview.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkswaava0r9wo66c0hxdg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkswaava0r9wo66c0hxdg.png" alt="Token bucket flow: refill, check tokens, allow or reject with 429" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Leaky Bucket
&lt;/h3&gt;

&lt;p&gt;Requests enter a queue. The queue drains at a fixed rate, like water leaking from a hole in a bucket. If the queue is full, new requests are dropped.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; Produces a perfectly smooth output rate.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cons:&lt;/strong&gt; Bursts of traffic fill the queue with old requests. Recent requests get starved.&lt;/p&gt;

&lt;p&gt;Good for systems that need steady processing, like a payment processor that calls a bank API.&lt;/p&gt;
&lt;h3&gt;
  
  
  3. Fixed Window Counter
&lt;/h3&gt;

&lt;p&gt;Split time into fixed windows, like one minute each. Keep one counter per window. Reject when the counter passes the limit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; Very simple. One counter per user.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cons:&lt;/strong&gt; The edge problem. A user can send 100 requests at 12:00:59 and another 100 at 12:01:00. That is 200 requests in two seconds, double the limit.&lt;/p&gt;
&lt;h3&gt;
  
  
  4. Sliding Window Log
&lt;/h3&gt;

&lt;p&gt;Store the timestamp of every request. On each new request, drop timestamps older than the window and count what is left.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; Perfectly accurate.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cons:&lt;/strong&gt; Memory heavy. A limit of 1,000 requests per hour means storing up to 1,000 timestamps per user.&lt;/p&gt;
&lt;h3&gt;
  
  
  5. Sliding Window Counter
&lt;/h3&gt;

&lt;p&gt;A hybrid. Keep counters for the current and previous window. Estimate the count with a weighted average.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;estimate = current_count + previous_count x (overlap percentage of previous window)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If we are 30% into the current minute, the previous minute still overlaps by 70%. So with 80 requests last minute and 20 so far this minute:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;20 + 80 x 0.7 = 76&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; Smooths out the edge problem. Memory efficient.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cons:&lt;/strong&gt; It is an approximation. Cloudflare measured it at about 0.003% error across 400 million requests, which is more than good enough.&lt;/p&gt;
&lt;h3&gt;
  
  
  Quick Comparison
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Algorithm&lt;/th&gt;
&lt;th&gt;Memory&lt;/th&gt;
&lt;th&gt;Accuracy&lt;/th&gt;
&lt;th&gt;Allows bursts&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Token bucket&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Good&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;General API limits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Leaky bucket&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Good&lt;/td&gt;
&lt;td&gt;No (smooths)&lt;/td&gt;
&lt;td&gt;Steady downstream calls&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fixed window&lt;/td&gt;
&lt;td&gt;Very low&lt;/td&gt;
&lt;td&gt;Weak at edges&lt;/td&gt;
&lt;td&gt;Yes, at edges&lt;/td&gt;
&lt;td&gt;Simple, low-stakes limits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sliding window log&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Exact&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Strict, low-volume limits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sliding window counter&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Very good&lt;/td&gt;
&lt;td&gt;Limited&lt;/td&gt;
&lt;td&gt;High-scale APIs&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;What I would say in the interview:&lt;/strong&gt; "I will go with the token bucket as the default because it is cheap, handles bursts, and is used in production by large API providers. If the business needs strict smoothing, I would switch to sliding window counter."&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 4: High-Level Design
&lt;/h2&gt;

&lt;p&gt;Now we draw boxes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fua1m757ptus9q5n3p0i1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fua1m757ptus9q5n3p0i1.png" alt="Rate limiter high-level design with API gateway, Redis cluster and rules service" width="799" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the flow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Client&lt;/strong&gt; sends a request.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API Gateway / Rate Limiter middleware&lt;/strong&gt; receives it. This is where the check happens.&lt;/li&gt;
&lt;li&gt;The middleware builds a key, like &lt;code&gt;rate:user:42&lt;/code&gt;, and checks the counter in &lt;strong&gt;Redis&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rules Service&lt;/strong&gt; stores the limits (for example, free tier gets 100 per minute, paid tier gets 1,000). The middleware caches these rules locally and refreshes them every few seconds.&lt;/li&gt;
&lt;li&gt;If the client is under the limit, the request goes to the &lt;strong&gt;API servers&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;If not, the middleware returns &lt;code&gt;429&lt;/code&gt; right away. The backend never sees it.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Where should the rate limiter live?
&lt;/h3&gt;

&lt;p&gt;Three options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Inside each service.&lt;/strong&gt; Simple, but every team rebuilds the same logic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;In the API gateway.&lt;/strong&gt; Central and consistent. This is the common choice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;As a separate service.&lt;/strong&gt; Flexible, but adds a network hop to every request.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I would pick the API gateway. If the company already runs a gateway like Kong, Envoy, or AWS API Gateway, rate limiting is a plugin away.&lt;/p&gt;
&lt;h3&gt;
  
  
  Why Redis?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In-memory, so reads and writes take under a millisecond.&lt;/li&gt;
&lt;li&gt;Built-in &lt;code&gt;INCR&lt;/code&gt; and &lt;code&gt;EXPIRE&lt;/code&gt; commands.&lt;/li&gt;
&lt;li&gt;Supports Lua scripts, which run atomically. That matters a lot. More on that next.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Response headers
&lt;/h3&gt;

&lt;p&gt;Be kind to clients. Tell them where they stand.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt; &lt;span class="m"&gt;429&lt;/span&gt; &lt;span class="ne"&gt;Too Many Requests&lt;/span&gt;
&lt;span class="na"&gt;X-RateLimit-Limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;100&lt;/span&gt;
&lt;span class="na"&gt;X-RateLimit-Remaining&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;0&lt;/span&gt;
&lt;span class="na"&gt;X-RateLimit-Reset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1696608000&lt;/span&gt;
&lt;span class="na"&gt;Retry-After&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;30&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Good clients read these headers and back off on their own. That reduces load before the limiter even has to say no.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Deep Dives (Where Senior Candidates Shine)
&lt;/h2&gt;

&lt;p&gt;A basic design gets you to "hire" at the mid level. These deep dives push you toward senior and staff.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deep Dive 1: Race Conditions
&lt;/h3&gt;

&lt;p&gt;Picture two API servers handling requests from the same user at the same moment.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Server A reads the counter: 99.&lt;/li&gt;
&lt;li&gt;Server B reads the counter: 99.&lt;/li&gt;
&lt;li&gt;Both see "under 100" and allow the request.&lt;/li&gt;
&lt;li&gt;Both write 100.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Two requests went through. The counter says one. Do this at scale and limits leak badly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Make read-check-write a single atomic step. In Redis, use a Lua script. Redis runs each script start to finish without interruption.&lt;/p&gt;

&lt;p&gt;Here is a token bucket in Lua:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lua"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- KEYS[1] = bucket key&lt;/span&gt;
&lt;span class="c1"&gt;-- ARGV[1] = capacity, ARGV[2] = refill rate per second, ARGV[3] = now (ms)&lt;/span&gt;
&lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="n"&gt;capacity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;tonumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ARGV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="n"&gt;rate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;tonumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ARGV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;tonumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ARGV&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="n"&gt;bucket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"HMGET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;KEYS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s2"&gt;"tokens"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"ts"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;tonumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;capacity&lt;/span&gt;
&lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="n"&gt;ts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;tonumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;

&lt;span class="c1"&gt;-- refill based on elapsed time&lt;/span&gt;
&lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="n"&gt;elapsed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;math.max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;ts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;
&lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;math.min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;capacity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;elapsed&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;rate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="n"&gt;allowed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
  &lt;span class="n"&gt;allowed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="n"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"HMSET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;KEYS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s2"&gt;"tokens"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"EXPIRE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;KEYS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nb"&gt;math.ceil&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;capacity&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;rate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;math.floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One network round trip. No races. No locks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deep Dive 2: Scaling Redis
&lt;/h3&gt;

&lt;p&gt;One Redis node will not last forever. Shard the keys across a Redis cluster using consistent hashing on the client key. All counters for &lt;code&gt;user:42&lt;/code&gt; land on the same shard, so the Lua script still works.&lt;/p&gt;

&lt;p&gt;Add a replica per shard for failover.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deep Dive 3: What If Redis Goes Down?
&lt;/h3&gt;

&lt;p&gt;This is a favorite follow-up. You have two choices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fail open.&lt;/strong&gt; Let all requests through. The API stays up, but you lose protection for a while.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fail closed.&lt;/strong&gt; Reject all requests. You stay protected, but your API is effectively down.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For most products, &lt;strong&gt;fail open&lt;/strong&gt; is the right call. A short window without limits hurts less than a full outage. Pair it with a local in-memory fallback limiter on each gateway node, so you still get rough protection.&lt;/p&gt;

&lt;p&gt;For security-critical limits, like login attempts, fail closed may be the safer choice. Say this trade-off out loud. Interviewers love it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deep Dive 4: Multi-Region
&lt;/h3&gt;

&lt;p&gt;If you run in three regions, a global limit gets tricky. Syncing every counter across regions on every request adds too much latency.&lt;/p&gt;

&lt;p&gt;Common approaches:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local limits per region.&lt;/strong&gt; Split the global limit (for example, 1,000 per minute becomes about 333 per region). Simple, slightly inaccurate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Async sync.&lt;/strong&gt; Each region counts locally and syncs totals every second or so. Accepts a small overshoot for much lower latency.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most real systems choose eventual consistency here. Perfect global accuracy is rarely worth the cost.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deep Dive 5: Reducing Load on Redis
&lt;/h3&gt;

&lt;p&gt;At very high traffic, even Redis can become a hot spot. Two tricks help:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local pre-check.&lt;/strong&gt; Each gateway keeps a small in-memory counter and only syncs with Redis in batches.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hot key handling.&lt;/strong&gt; A single huge customer can overload one shard. Split their key into sub-keys (&lt;code&gt;rate:user:42:0&lt;/code&gt; to &lt;code&gt;rate:user:42:3&lt;/code&gt;) and divide their limit across them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What Interviewers Actually Look For
&lt;/h2&gt;

&lt;p&gt;Here is how I would grade this question, based on years of running these interviews.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Level&lt;/th&gt;
&lt;th&gt;What a strong answer includes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Junior / Mid&lt;/td&gt;
&lt;td&gt;Clear requirements, one algorithm explained well, gateway plus Redis design&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Senior&lt;/td&gt;
&lt;td&gt;Compares algorithms with trade-offs, solves race conditions, discusses fail open vs fail closed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Staff&lt;/td&gt;
&lt;td&gt;Multi-region strategy, hot keys, rule management, and how clients should react to &lt;code&gt;429&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;You do not need every deep dive. Pick two and go deep. Depth beats breadth.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mistakes to Avoid
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Jumping to Redis before asking a single question.&lt;/li&gt;
&lt;li&gt;Explaining five algorithms and never picking one.&lt;/li&gt;
&lt;li&gt;Forgetting the race condition.&lt;/li&gt;
&lt;li&gt;Ignoring what happens when the rate limiter itself fails.&lt;/li&gt;
&lt;li&gt;Storing counters in a relational database. Too slow for a per-request check.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A rate limiter caps how many requests a client can make in a time window.&lt;/li&gt;
&lt;li&gt;Always clarify: what to limit by, scale, distributed or not, hard or soft limits.&lt;/li&gt;
&lt;li&gt;Token bucket is the best default. Sliding window counter is great for high-scale accuracy.&lt;/li&gt;
&lt;li&gt;Put the limiter in the API gateway and store counters in Redis.&lt;/li&gt;
&lt;li&gt;Use Lua scripts to make the check atomic and avoid race conditions.&lt;/li&gt;
&lt;li&gt;Fail open for most APIs. Fail closed for security-critical limits.&lt;/li&gt;
&lt;li&gt;For multiple regions, accept small inaccuracy in exchange for low latency.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What HTTP status code should a rate limiter return?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;code&gt;429 Too Many Requests&lt;/code&gt;, along with a &lt;code&gt;Retry-After&lt;/code&gt; header that tells the client when to try again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which rate limiting algorithm is best?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
There is no single best one. Token bucket is the most common default because it is simple, cheap, and allows short bursts. Sliding window counter is better when you need smoother limits at scale.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why use Redis instead of a database?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The check runs on every single request. Redis is in-memory and answers in under a millisecond. A disk-based database would add too much latency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the difference between token bucket and leaky bucket?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Token bucket allows bursts up to the bucket size. Leaky bucket smooths everything into a steady output rate, even if requests arrive in bursts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Should the rate limiter fail open or fail closed?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Usually fail open, so a limiter outage does not become an API outage. For login or payment endpoints, failing closed can be safer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How long should I spend on this in a 45-minute interview?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
About 5 minutes on requirements, 5 on estimates, 10 on algorithms, 10 on the high-level design, and the rest on one or two deep dives.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;The rate limiter is a great interview question because it looks easy. The candidates who stand out are the ones who slow down, ask the right questions, and talk openly about trade-offs.&lt;/p&gt;

&lt;p&gt;If you want more walkthroughs like this one, including URL shorteners, news feeds, and chat systems, they are all covered in &lt;a href="https://www.designgurus.io/course/grokking-the-system-design-interview" rel="noopener noreferrer"&gt;Grokking the System Design Interview&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Which system design question should I break down next? Let me know in the comments.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>architecture</category>
      <category>interview</category>
      <category>backend</category>
    </item>
    <item>
      <title>LeetCode Patterns: The Complete List of 20 to Master (With Examples)</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Tue, 06 Oct 2026 04:55:28 +0000</pubDate>
      <link>https://dev.to/arslan_ah/leetcode-patterns-the-complete-list-of-20-to-master-with-examples-nff</link>
      <guid>https://dev.to/arslan_ah/leetcode-patterns-the-complete-list-of-20-to-master-with-examples-nff</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;The complete list of 20 LeetCode patterns. Each one carries the signal that identifies it in a problem statement, a code template you can reuse, and three practice problems on LeetCode. Pattern problem counts come from LeetCode's own topic tags.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;LeetCode has 4,073 problems. Nobody solves them all, and nobody needs to.&lt;/p&gt;

&lt;p&gt;The questions are generated from a much smaller set of reusable approaches. Learn to recognize those, and a problem you have never seen becomes a variation of one you have. Miss them, and every question feels new, which is why solving hundreds of problems at random produces so little.&lt;/p&gt;

&lt;p&gt;This guide covers all 20 patterns. For each one you get the cue that gives it away, why it works, a short template in Python, and three real LeetCode problems to practice on. The order is by what each pattern returns against LeetCode's actual problem distribution, so the earliest entries are the ones worth learning first.&lt;/p&gt;

&lt;p&gt;You will see these called LeetCode patterns, LC patterns, coding patterns, or DSA patterns. They are the same thing: a reusable approach that pairs an algorithmic technique with the data structure it runs on. A single LeetCode pattern is worth more than a hundred solved problems, because the pattern transfers and the solved problem does not.&lt;/p&gt;

&lt;p&gt;If you want the same 20 as a short reference instead, see the &lt;a href="https://www.designgurus.io/blog/grokking-the-coding-interview-patterns?utm_source=devto" rel="noopener noreferrer"&gt;coding interview patterns catalog&lt;/a&gt;. If you want to train the recognition skill itself rather than read the list, see &lt;a href="https://www.grokkingthecodinginterview.com/blog/leetcode-patterns" rel="noopener noreferrer"&gt;how to read a problem statement and name the pattern&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  All 20 LeetCode Patterns
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Two Pointers&lt;/li&gt;
&lt;li&gt;Sliding Window&lt;/li&gt;
&lt;li&gt;Modified Binary Search&lt;/li&gt;
&lt;li&gt;Tree Depth First Search&lt;/li&gt;
&lt;li&gt;Tree Breadth First Search&lt;/li&gt;
&lt;li&gt;Island (Matrix Traversal)&lt;/li&gt;
&lt;li&gt;0/1 Knapsack (Dynamic Programming)&lt;/li&gt;
&lt;li&gt;Top 'K' Elements&lt;/li&gt;
&lt;li&gt;Backtracking&lt;/li&gt;
&lt;li&gt;Subsets&lt;/li&gt;
&lt;li&gt;Bitwise XOR&lt;/li&gt;
&lt;li&gt;Fast &amp;amp; Slow Pointers&lt;/li&gt;
&lt;li&gt;Merge Intervals&lt;/li&gt;
&lt;li&gt;Monotonic Stack&lt;/li&gt;
&lt;li&gt;Topological Sort&lt;/li&gt;
&lt;li&gt;In-place Reversal of a Linked List&lt;/li&gt;
&lt;li&gt;Two Heaps&lt;/li&gt;
&lt;li&gt;Cyclic Sort&lt;/li&gt;
&lt;li&gt;K-way Merge&lt;/li&gt;
&lt;li&gt;Multi-threaded&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fos2dv7d7x2t9n7q0rh0g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fos2dv7d7x2t9n7q0rh0g.png" alt="The 20 LeetCode patterns at a glance" width="800" height="724"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The 20 Patterns at a Glance
&lt;/h2&gt;

&lt;p&gt;Problem counts are LeetCode topic-tag totals, pulled from LeetCode. A few patterns share a tag and two have no dedicated tag, which is noted rather than guessed.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Pattern&lt;/th&gt;
&lt;th&gt;Recognize it by&lt;/th&gt;
&lt;th&gt;Time&lt;/th&gt;
&lt;th&gt;LeetCode problems&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1. Two Pointers
&lt;/td&gt;
&lt;td&gt;sorted input, find a pair or triplet&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;263&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2. Sliding Window
&lt;/td&gt;
&lt;td&gt;longest or shortest contiguous run&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;175&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3. Modified Binary Search
&lt;/td&gt;
&lt;td&gt;sorted or rotated, or a testable answer&lt;/td&gt;
&lt;td&gt;O(log n) time&lt;/td&gt;
&lt;td&gt;356&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4. Tree Depth First Search
&lt;/td&gt;
&lt;td&gt;root-to-leaf path, or a subtree answer&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;349&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5. Tree Breadth First Search
&lt;/td&gt;
&lt;td&gt;levels, or fewest steps&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;260&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6. Island (Matrix Traversal)
&lt;/td&gt;
&lt;td&gt;a grid, count connected regions&lt;/td&gt;
&lt;td&gt;O(m*n) time&lt;/td&gt;
&lt;td&gt;285&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7. 0/1 Knapsack (Dynamic Programming)
&lt;/td&gt;
&lt;td&gt;pick a subset under a capacity&lt;/td&gt;
&lt;td&gt;O(n*C) time&lt;/td&gt;
&lt;td&gt;684&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8. Top 'K' Elements
&lt;/td&gt;
&lt;td&gt;k largest, smallest, or most frequent&lt;/td&gt;
&lt;td&gt;O(n log k) time&lt;/td&gt;
&lt;td&gt;222&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9. Backtracking
&lt;/td&gt;
&lt;td&gt;list every valid configuration&lt;/td&gt;
&lt;td&gt;O(b^d) time&lt;/td&gt;
&lt;td&gt;114&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10. Subsets
&lt;/td&gt;
&lt;td&gt;every combination or power set&lt;/td&gt;
&lt;td&gt;O(n * 2^n) time&lt;/td&gt;
&lt;td&gt;114&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;11. Bitwise XOR
&lt;/td&gt;
&lt;td&gt;values pair off, find the odd one out&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;297&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12. Fast &amp;amp; Slow Pointers
&lt;/td&gt;
&lt;td&gt;cycle, middle, or kth from the end&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;263&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13. Merge Intervals
&lt;/td&gt;
&lt;td&gt;ranges or time slots that overlap&lt;/td&gt;
&lt;td&gt;O(n log n) time&lt;/td&gt;
&lt;td&gt;no dedicated tag&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;14. Monotonic Stack
&lt;/td&gt;
&lt;td&gt;next greater or next smaller element&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;76&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;15. Topological Sort
&lt;/td&gt;
&lt;td&gt;prerequisites, ordering, cycle check&lt;/td&gt;
&lt;td&gt;O(V+E) time&lt;/td&gt;
&lt;td&gt;40&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;16. In-place Reversal of a Linked List
&lt;/td&gt;
&lt;td&gt;reverse a list without new memory&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;82&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;17. Two Heaps
&lt;/td&gt;
&lt;td&gt;running median, or a split set&lt;/td&gt;
&lt;td&gt;O(log n) insert&lt;/td&gt;
&lt;td&gt;222&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;18. Cyclic Sort
&lt;/td&gt;
&lt;td&gt;a permutation of 1..n&lt;/td&gt;
&lt;td&gt;O(n) time&lt;/td&gt;
&lt;td&gt;no dedicated tag&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;19. K-way Merge
&lt;/td&gt;
&lt;td&gt;k sorted lists to combine&lt;/td&gt;
&lt;td&gt;O(n log k) time&lt;/td&gt;
&lt;td&gt;17&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20. Multi-threaded
&lt;/td&gt;
&lt;td&gt;coordinate or order concurrent work&lt;/td&gt;
&lt;td&gt;depends on the coordination primitive&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The Most Common LeetCode Patterns
&lt;/h2&gt;

&lt;p&gt;If you only have time for part of this list, the eight most common LeetCode patterns are the first eight above: Two Pointers, Sliding Window, Modified Binary Search, Tree Depth First Search, Tree Breadth First Search, Island (Matrix Traversal), 0/1 Knapsack, and Top 'K' Elements.&lt;/p&gt;

&lt;p&gt;Those eight are also the most important ones to get automatic, because they are the patterns an interviewer is most likely to reach for and the ones whose variations show up across the widest range of questions. Together they account for the large majority of what gets asked in a standard coding loop.&lt;/p&gt;

&lt;p&gt;One warning about reading tag counts straight. Bitwise XOR carries 297 tagged problems, which is more than Sliding Window's 175, but almost all of those are narrow puzzles rather than interview staples. A large tag means the technique is common in the problem set, not that it is common in interviews. The order on this page accounts for that; a raw tag ranking does not.&lt;/p&gt;

&lt;h2&gt;
  
  
  LeetCode Patterns Cheat Sheet: What the Wording Tells You
&lt;/h2&gt;

&lt;p&gt;Pattern recognition is mostly vocabulary. The same phrases appear in problem statements again and again, and each one points at a small number of patterns. Use this as a lookup while you practice, then stop using it once the mapping is automatic.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;If the problem says&lt;/th&gt;
&lt;th&gt;Reach for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;"sorted array" plus "find a pair / triplet"&lt;/td&gt;
&lt;td&gt;Two Pointers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"longest" or "shortest" plus "substring" or "subarray"&lt;/td&gt;
&lt;td&gt;Sliding Window&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"at most K" or "exactly K distinct"&lt;/td&gt;
&lt;td&gt;Sliding Window&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"rotated sorted array"&lt;/td&gt;
&lt;td&gt;Modified Binary Search&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"minimum / maximum value such that ..."&lt;/td&gt;
&lt;td&gt;Modified Binary Search&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"root-to-leaf" or "path sum"&lt;/td&gt;
&lt;td&gt;Tree Depth First Search&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"level order" or "level by level"&lt;/td&gt;
&lt;td&gt;Tree Breadth First Search&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"shortest number of steps" on a graph or grid&lt;/td&gt;
&lt;td&gt;Tree Breadth First Search&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"grid" plus "connected" or "regions" or "islands"&lt;/td&gt;
&lt;td&gt;Island (Matrix Traversal)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"can you partition" or "reach exactly this total"&lt;/td&gt;
&lt;td&gt;0/1 Knapsack (Dynamic Programming)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"fewest coins" or "ways to make up"&lt;/td&gt;
&lt;td&gt;0/1 Knapsack (Dynamic Programming)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"top K" or "K most frequent" or "K closest"&lt;/td&gt;
&lt;td&gt;Top 'K' Elements&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"all permutations" or "all valid boards"&lt;/td&gt;
&lt;td&gt;Backtracking&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"all subsets" or "power set" or "all combinations"&lt;/td&gt;
&lt;td&gt;Subsets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"every element appears twice except one"&lt;/td&gt;
&lt;td&gt;Bitwise XOR&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"cycle", "middle node", or "Nth from the end"&lt;/td&gt;
&lt;td&gt;Fast &amp;amp; Slow Pointers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"intervals", "meetings", or "time slots"&lt;/td&gt;
&lt;td&gt;Merge Intervals&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"next greater" or "next smaller" element&lt;/td&gt;
&lt;td&gt;Monotonic Stack&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"prerequisites", "course order", or "build order"&lt;/td&gt;
&lt;td&gt;Topological Sort&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"reverse the list" with O(1) extra space&lt;/td&gt;
&lt;td&gt;In-place Reversal of a Linked List&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"median" of a stream or a window&lt;/td&gt;
&lt;td&gt;Two Heaps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"numbers from 1 to n" with one missing or duplicated&lt;/td&gt;
&lt;td&gt;Cyclic Sort&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"K sorted lists" or "K sorted arrays"&lt;/td&gt;
&lt;td&gt;K-way Merge&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"threads must run in order"&lt;/td&gt;
&lt;td&gt;Multi-threaded&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two cautions. A problem can carry more than one of these signals, in which case the patterns usually compose rather than compete, such as a sliding window over a monotonic stack. And a phrase is evidence, not proof; confirm against the constraints before you commit to an approach.&lt;/p&gt;

&lt;p&gt;If you want to train this recognition rather than look it up, &lt;a href="https://www.grokkingthecodinginterview.com/blog/leetcode-patterns" rel="noopener noreferrer"&gt;this walkthrough reads a problem statement and names the pattern step by step&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two Pointers
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the input is sorted, or you need a pair, triplet, or subsequence that satisfies a condition.&lt;/p&gt;

&lt;p&gt;Two indices moving toward each other turn an O(n^2) scan of every pair into a single O(n) pass, because a sorted order tells you which pointer to move.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn5giwje193fmzergasz4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn5giwje193fmzergasz4.png" alt="Two Pointers pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;two_sum_sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;          &lt;span class="c1"&gt;# need a bigger sum
&lt;/span&gt;        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;          &lt;span class="c1"&gt;# need a smaller sum
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(1) space. LeetCode tags &lt;strong&gt;263&lt;/strong&gt; problems with &lt;code&gt;two-pointers&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/" rel="noopener noreferrer"&gt;Two Sum II - Input Array Is Sorted&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/3sum/" rel="noopener noreferrer"&gt;3Sum&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/container-with-most-water/" rel="noopener noreferrer"&gt;Container With Most Water&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sliding Window
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the question asks for the longest, shortest, or best contiguous subarray or substring.&lt;/p&gt;

&lt;p&gt;The window expands to include new elements and contracts to restore the constraint, so each element is visited at most twice instead of being re-scanned for every start index.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5zs61jhytwpv2eh711wg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5zs61jhytwpv2eh711wg.png" alt="Sliding Window pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;longest_unique&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;best&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ch&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ch&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;      &lt;span class="c1"&gt;# contract past the duplicate
&lt;/span&gt;        &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt;
        &lt;span class="n"&gt;best&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;best&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;best&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(k) space. LeetCode tags &lt;strong&gt;175&lt;/strong&gt; problems with &lt;code&gt;sliding-window&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/longest-substring-without-repeating-characters/" rel="noopener noreferrer"&gt;Longest Substring Without Repeating Characters&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/minimum-window-substring/" rel="noopener noreferrer"&gt;Minimum Window Substring&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/maximum-average-subarray-i/" rel="noopener noreferrer"&gt;Maximum Average Subarray I&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Modified Binary Search
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the input is sorted or rotated, or the answer itself is a number you can test for feasibility.&lt;/p&gt;

&lt;p&gt;Any question where a candidate answer can be checked in O(n) becomes O(n log n) by binary searching the answer space rather than the array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fizrcka6maa6q4ff626x3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fizrcka6maa6q4ff626x3.png" alt="Modified Binary Search pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;search_rotated&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;            &lt;span class="c1"&gt;# left half is sorted
&lt;/span&gt;            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
                &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                                &lt;span class="c1"&gt;# right half is sorted
&lt;/span&gt;            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
                &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(log n) time, O(1) space. LeetCode tags &lt;strong&gt;356&lt;/strong&gt; problems with &lt;code&gt;binary-search&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/search-in-rotated-sorted-array/" rel="noopener noreferrer"&gt;Search in Rotated Sorted Array&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/" rel="noopener noreferrer"&gt;Find Minimum in Rotated Sorted Array&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/koko-eating-bananas/" rel="noopener noreferrer"&gt;Koko Eating Bananas&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tree Depth First Search
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the answer depends on a full root-to-leaf path, or on information returned from a subtree.&lt;/p&gt;

&lt;p&gt;Recursion carries state down the path and returns an answer back up, which is exactly the shape of path sums, depths, and subtree validity checks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fs1dwkormqexigp9ei1aq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fs1dwkormqexigp9ei1aq.png" alt="Tree Depth First Search pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;has_path_sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
    &lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="c1"&gt;# leaf
&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;has_path_sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="nf"&gt;has_path_sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(h) space. LeetCode tags &lt;strong&gt;349&lt;/strong&gt; problems with &lt;code&gt;depth-first-search&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/maximum-depth-of-binary-tree/" rel="noopener noreferrer"&gt;Maximum Depth of Binary Tree&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/path-sum/" rel="noopener noreferrer"&gt;Path Sum&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/validate-binary-search-tree/" rel="noopener noreferrer"&gt;Validate Binary Search Tree&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tree Breadth First Search
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the question mentions levels, or asks for the shortest number of steps.&lt;/p&gt;

&lt;p&gt;A queue visits every node at distance k before any node at distance k+1, so the first time you reach a target you have reached it by the shortest route.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqlqfxx8lfcl35owkey3q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqlqfxx8lfcl35owkey3q.png" alt="Tree Breadth First Search pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;collections&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;deque&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;level_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="nf"&gt;deque&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;level&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;              &lt;span class="c1"&gt;# freeze the level width
&lt;/span&gt;            &lt;span class="n"&gt;node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;popleft&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="n"&gt;level&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;level&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(w) space. LeetCode tags &lt;strong&gt;260&lt;/strong&gt; problems with &lt;code&gt;breadth-first-search&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/binary-tree-level-order-traversal/" rel="noopener noreferrer"&gt;Binary Tree Level Order Traversal&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/" rel="noopener noreferrer"&gt;Binary Tree Zigzag Level Order Traversal&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/minimum-depth-of-binary-tree/" rel="noopener noreferrer"&gt;Minimum Depth of Binary Tree&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Island (Matrix Traversal)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the input is a grid and you need to find or count connected regions.&lt;/p&gt;

&lt;p&gt;A grid is a graph whose neighbors are implicit, so one flood fill per unvisited cell counts regions in a single pass over the matrix.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F59g0frlilbx7zkayori3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F59g0frlilbx7zkayori3.png" alt="Island (Matrix Traversal) pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;num_islands&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cols&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;cols&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt;
        &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;                     &lt;span class="c1"&gt;# mark visited in place
&lt;/span&gt;        &lt;span class="nf"&gt;sink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nf"&gt;sink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nf"&gt;sink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nf"&gt;sink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cols&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
                &lt;span class="nf"&gt;sink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(m*n) time, O(m*n) space. LeetCode tags &lt;strong&gt;285&lt;/strong&gt; problems with &lt;code&gt;matrix&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/number-of-islands/" rel="noopener noreferrer"&gt;Number of Islands&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/max-area-of-island/" rel="noopener noreferrer"&gt;Max Area of Island&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/surrounded-regions/" rel="noopener noreferrer"&gt;Surrounded Regions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  0/1 Knapsack (Dynamic Programming)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; you must choose a subset under a capacity or budget, and subproblems repeat.&lt;/p&gt;

&lt;p&gt;Each item is either taken or skipped, so the answer for a capacity depends only on smaller capacities, which a table fills once instead of re-deriving exponentially.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc7o34m6houkwa0odfuk5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc7o34m6houkwa0odfuk5.png" alt="0/1 Knapsack (Dynamic Programming) pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;can_partition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
    &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
    &lt;span class="n"&gt;dp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;cap&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;   &lt;span class="c1"&gt;# backwards: each item once
&lt;/span&gt;            &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;cap&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;cap&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;cap&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n*C) time, O(C) space. LeetCode tags &lt;strong&gt;684&lt;/strong&gt; problems with &lt;code&gt;dynamic-programming&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/partition-equal-subset-sum/" rel="noopener noreferrer"&gt;Partition Equal Subset Sum&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/coin-change/" rel="noopener noreferrer"&gt;Coin Change&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/target-sum/" rel="noopener noreferrer"&gt;Target Sum&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Top 'K' Elements
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the question asks for the k largest, k smallest, k most frequent, or k closest.&lt;/p&gt;

&lt;p&gt;A heap of size k keeps only the candidates that can still win, which costs O(n log k) instead of the O(n log n) of sorting everything.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffmq44i3tet1hk3kkjin4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffmq44i3tet1hk3kkjin4.png" alt="Top 'K' Elements pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;heapq&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;kth_largest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;heap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;              &lt;span class="c1"&gt;# drop the smallest candidate
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n log k) time, O(k) space. LeetCode tags &lt;strong&gt;222&lt;/strong&gt; problems with &lt;code&gt;heap-priority-queue&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/kth-largest-element-in-an-array/" rel="noopener noreferrer"&gt;Kth Largest Element in an Array&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/top-k-frequent-elements/" rel="noopener noreferrer"&gt;Top K Frequent Elements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/k-closest-points-to-origin/" rel="noopener noreferrer"&gt;K Closest Points to Origin&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Backtracking
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the question asks for all valid configurations, not just a count or a best one.&lt;/p&gt;

&lt;p&gt;You build a candidate one choice at a time and undo the choice on the way out, which explores the whole space while holding only one path in memory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbzb2vp0ggs3qv7p7pydp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbzb2vp0ggs3qv7p7pydp.png" alt="Backtracking pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;permute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;[:])&lt;/span&gt;              &lt;span class="c1"&gt;# copy, the path mutates
&lt;/span&gt;            &lt;span class="k"&gt;return&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
                &lt;span class="k"&gt;continue&lt;/span&gt;
            &lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;      &lt;span class="c1"&gt;# undo
&lt;/span&gt;    &lt;span class="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(b^d) time, O(d) space. LeetCode tags &lt;strong&gt;114&lt;/strong&gt; problems with &lt;code&gt;backtracking&lt;/code&gt;, and it shares the backtracking tag with Subsets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/permutations/" rel="noopener noreferrer"&gt;Permutations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/n-queens/" rel="noopener noreferrer"&gt;N-Queens&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/word-search/" rel="noopener noreferrer"&gt;Word Search&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Subsets
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; you need every combination, subset, or power set of the input.&lt;/p&gt;

&lt;p&gt;Each element is in or out, so the answer set doubles per element, and you can build it iteratively by cloning what you already have.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5bm86mvcqzdnw73mcvcj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5bm86mvcqzdnw73mcvcj.png" alt="Subsets pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;subsets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[[]]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;cur&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;    &lt;span class="c1"&gt;# clone everything, add n
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n * 2^n) time, O(n * 2^n) space. LeetCode tags &lt;strong&gt;114&lt;/strong&gt; problems with &lt;code&gt;backtracking&lt;/code&gt;, and it shares the backtracking tag with Backtracking.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/subsets/" rel="noopener noreferrer"&gt;Subsets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/subsets-ii/" rel="noopener noreferrer"&gt;Subsets II&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/letter-combinations-of-a-phone-number/" rel="noopener noreferrer"&gt;Letter Combinations of a Phone Number&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Bitwise XOR
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; elements pair up and cancel, or you are asked to find a single missing or unique value.&lt;/p&gt;

&lt;p&gt;XOR of a value with itself is zero and XOR is order independent, so every duplicate cancels and the lone survivor is the answer in O(1) space.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk7bs3qc1tq79k0oafmbn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk7bs3qc1tq79k0oafmbn.png" alt="Bitwise XOR pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;single_number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;^=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;                             &lt;span class="c1"&gt;# pairs cancel to 0
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(1) space. LeetCode tags &lt;strong&gt;297&lt;/strong&gt; problems with &lt;code&gt;bit-manipulation&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/single-number/" rel="noopener noreferrer"&gt;Single Number&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/missing-number/" rel="noopener noreferrer"&gt;Missing Number&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/find-the-duplicate-number/" rel="noopener noreferrer"&gt;Find the Duplicate Number&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Fast &amp;amp; Slow Pointers
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the input is a linked list or an implicit sequence, and you need a cycle, a middle, or a kth-from-end node.&lt;/p&gt;

&lt;p&gt;Two pointers at different speeds meet inside a cycle and land the slow one at the middle on a straight run, with no extra memory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq61l2z27thpciyxvwuev.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq61l2z27thpciyxvwuev.png" alt="Fast &amp;amp; Slow Pointers pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;has_cycle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;slow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fast&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;head&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;fast&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;fast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;slow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;slow&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;                     &lt;span class="c1"&gt;# one step
&lt;/span&gt;        &lt;span class="n"&gt;fast&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;                &lt;span class="c1"&gt;# two steps
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;slow&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="n"&gt;fast&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(1) space. LeetCode tags &lt;strong&gt;263&lt;/strong&gt; problems with &lt;code&gt;two-pointers&lt;/code&gt;, and it shares the two-pointers tag with Two Pointers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/linked-list-cycle/" rel="noopener noreferrer"&gt;Linked List Cycle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/middle-of-the-linked-list/" rel="noopener noreferrer"&gt;Middle of the Linked List&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/happy-number/" rel="noopener noreferrer"&gt;Happy Number&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Merge Intervals
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the input is a list of ranges, meetings, or time slots that may overlap.&lt;/p&gt;

&lt;p&gt;Once intervals are sorted by start, every overlap is adjacent, so one pass merges or counts them without comparing all pairs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fv3ig0elbis0uey4gw9j8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fv3ig0elbis0uey4gw9j8.png" alt="Merge Intervals pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;merge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;intervals&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;intervals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;iv&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;iv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;intervals&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;      &lt;span class="c1"&gt;# overlaps the previous
&lt;/span&gt;            &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n log n) time, O(n) space. LeetCode has no dedicated tag for this one; these sit under array and sorting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/merge-intervals/" rel="noopener noreferrer"&gt;Merge Intervals&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/insert-interval/" rel="noopener noreferrer"&gt;Insert Interval&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/non-overlapping-intervals/" rel="noopener noreferrer"&gt;Non-overlapping Intervals&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Monotonic Stack
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; you need the next greater or next smaller element, or the span a value dominates.&lt;/p&gt;

&lt;p&gt;A stack kept in sorted order discards elements that can never be an answer again, so every element is pushed and popped at most once.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F81dbkercuxvoeoi9exdl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F81dbkercuxvoeoi9exdl.png" alt="Monotonic Stack pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;daily_temperatures&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;temps&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;temps&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;        &lt;span class="c1"&gt;# stack holds indices
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;temps&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;temps&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt;
        &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(n) space. LeetCode tags &lt;strong&gt;76&lt;/strong&gt; problems with &lt;code&gt;monotonic-stack&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/next-greater-element-i/" rel="noopener noreferrer"&gt;Next Greater Element I&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/daily-temperatures/" rel="noopener noreferrer"&gt;Daily Temperatures&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/largest-rectangle-in-histogram/" rel="noopener noreferrer"&gt;Largest Rectangle in Histogram&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Topological Sort
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; tasks, courses, or builds have prerequisites, and you need a valid order or a cycle check.&lt;/p&gt;

&lt;p&gt;Repeatedly removing nodes with no remaining prerequisites produces a legal order, and a leftover node proves a cycle exists.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F48yknse4eosqm7ca49ki.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F48yknse4eosqm7ca49ki.png" alt="Topological Sort pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;collections&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;deque&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;find_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prereqs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;graph&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indeg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[[]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;course&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;need&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;prereqs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;graph&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;need&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;course&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;indeg&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;course&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;deque&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;indeg&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;popleft&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;nxt&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;graph&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
            &lt;span class="n"&gt;indeg&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;nxt&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;indeg&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;nxt&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nxt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;      &lt;span class="c1"&gt;# short means a cycle
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(V+E) time, O(V+E) space. LeetCode tags &lt;strong&gt;40&lt;/strong&gt; problems with &lt;code&gt;topological-sort&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/course-schedule/" rel="noopener noreferrer"&gt;Course Schedule&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/course-schedule-ii/" rel="noopener noreferrer"&gt;Course Schedule II&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/minimum-height-trees/" rel="noopener noreferrer"&gt;Minimum Height Trees&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  In-place Reversal of a Linked List
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; you must reverse a list or a sublist without allocating a new one.&lt;/p&gt;

&lt;p&gt;Rewiring the next pointer of each node as you walk reverses the list in one pass and O(1) extra space.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx1zr7ysr4hlnwzohnfpp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx1zr7ysr4hlnwzohnfpp.png" alt="In-place Reversal of a Linked List pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;reverse_list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;prev&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;head&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;nxt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;                       &lt;span class="c1"&gt;# save before overwriting
&lt;/span&gt;        &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;prev&lt;/span&gt;
        &lt;span class="n"&gt;prev&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nxt&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;prev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(1) space. LeetCode tags &lt;strong&gt;82&lt;/strong&gt; problems with &lt;code&gt;linked-list&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/reverse-linked-list/" rel="noopener noreferrer"&gt;Reverse Linked List&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/reverse-linked-list-ii/" rel="noopener noreferrer"&gt;Reverse Linked List II&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/reverse-nodes-in-k-group/" rel="noopener noreferrer"&gt;Reverse Nodes in k-Group&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Two Heaps
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; you need a running median, or to keep a set split into a smaller half and a larger half.&lt;/p&gt;

&lt;p&gt;A max-heap over the low half and a min-heap over the high half put the middle value at the two tops, so the median is O(1) to read.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpdh697xlipxlqy7w8atk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpdh697xlipxlqy7w8atk.png" alt="Two Heaps pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;heapq&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MedianFinder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;high&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;         &lt;span class="c1"&gt;# low is a max-heap (negated)
&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;median&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="nf"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(log n) insert, O(1) median. LeetCode tags &lt;strong&gt;222&lt;/strong&gt; problems with &lt;code&gt;heap-priority-queue&lt;/code&gt;, and it shares the heap tag with Top 'K' Elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/find-median-from-data-stream/" rel="noopener noreferrer"&gt;Find Median from Data Stream&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/sliding-window-median/" rel="noopener noreferrer"&gt;Sliding Window Median&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/ipo/" rel="noopener noreferrer"&gt;IPO&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Cyclic Sort
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the input is a permutation of numbers in a known range such as 1 to n.&lt;/p&gt;

&lt;p&gt;When a value implies its own index, swapping each number home sorts the array in O(n) with no extra space, which exposes missing and duplicate values.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvtvwh7dyi5zza59u5x7u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvtvwh7dyi5zza59u5x7u.png" alt="Cyclic Sort pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;cyclic_sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;home&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;                   &lt;span class="c1"&gt;# value n belongs at index n-1
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;home&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
            &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n) time, O(1) space. LeetCode has no dedicated tag for this one; these sit under array and sorting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/missing-number/" rel="noopener noreferrer"&gt;Missing Number&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/" rel="noopener noreferrer"&gt;Find All Numbers Disappeared in an Array&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/first-missing-positive/" rel="noopener noreferrer"&gt;First Missing Positive&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  K-way Merge
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; you are given k sorted lists, arrays, or streams to combine or search across.&lt;/p&gt;

&lt;p&gt;A heap holding one candidate from each list always exposes the global smallest next element, so the merge costs O(n log k).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7e3jwm7i0yvkvc01y0vi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7e3jwm7i0yvkvc01y0vi.png" alt="K-way Merge pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;heapq&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;merge_k_sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lists&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;heap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lst&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lists&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heapify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lists&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="p"&gt;]):&lt;/span&gt;         &lt;span class="c1"&gt;# refill from the same list
&lt;/span&gt;            &lt;span class="n"&gt;heapq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heappush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heap&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lists&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; O(n log k) time, O(k) space. LeetCode tags &lt;strong&gt;17&lt;/strong&gt; problems with &lt;code&gt;merge-sort&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/merge-k-sorted-lists/" rel="noopener noreferrer"&gt;Merge k Sorted Lists&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/" rel="noopener noreferrer"&gt;Kth Smallest Element in a Sorted Matrix&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/find-k-pairs-with-smallest-sums/" rel="noopener noreferrer"&gt;Find K Pairs with Smallest Sums&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Multi-threaded
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use it when&lt;/strong&gt; the question asks you to coordinate concurrent work, or to enforce an order between threads.&lt;/p&gt;

&lt;p&gt;The algorithm is usually trivial; what is graded is whether you reach for the right primitive and avoid a race or a deadlock.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx8k53ci8oxph6jaubt3p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx8k53ci8oxph6jaubt3p.png" alt="Multi-threaded pattern diagram" width="800" height="329"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;threading&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Foo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;second&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;threading&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Semaphore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;third&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;threading&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Semaphore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;first&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;printFirst&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;printFirst&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;second&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;release&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;                &lt;span class="c1"&gt;# unblock the next stage
&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;second_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;printSecond&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;second&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;acquire&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="nf"&gt;printSecond&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;third&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;release&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;third_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;printThird&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;third&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;acquire&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="nf"&gt;printThird&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity:&lt;/strong&gt; depends on the coordination primitive. LeetCode tags &lt;strong&gt;9&lt;/strong&gt; problems with &lt;code&gt;concurrency&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice on LeetCode:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/print-in-order/" rel="noopener noreferrer"&gt;Print in Order&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/print-foobar-alternately/" rel="noopener noreferrer"&gt;Print FooBar Alternately&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/building-h2o/" rel="noopener noreferrer"&gt;Building H2O&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Which LeetCode Patterns Are Most Important
&lt;/h2&gt;

&lt;p&gt;This is the part most pattern lists leave out. Not every pattern earns the same return, because LeetCode's own problems are not evenly spread across them.&lt;/p&gt;

&lt;p&gt;Every question on LeetCode carries one or more topic tags. Counting those tags shows where the problems actually are, which is a better guide to study order than any opinion. Here are the 20 largest tags across the 4,073 problems.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;LeetCode topic tag&lt;/th&gt;
&lt;th&gt;Problems&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Array&lt;/td&gt;
&lt;td&gt;2273&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;String&lt;/td&gt;
&lt;td&gt;895&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hash Table&lt;/td&gt;
&lt;td&gt;843&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dynamic Programming&lt;/td&gt;
&lt;td&gt;684&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sorting&lt;/td&gt;
&lt;td&gt;540&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Greedy&lt;/td&gt;
&lt;td&gt;483&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Binary Search&lt;/td&gt;
&lt;td&gt;356&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Depth-First Search&lt;/td&gt;
&lt;td&gt;349&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bit Manipulation&lt;/td&gt;
&lt;td&gt;297&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Matrix&lt;/td&gt;
&lt;td&gt;285&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Prefix Sum&lt;/td&gt;
&lt;td&gt;277&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tree&lt;/td&gt;
&lt;td&gt;270&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Two Pointers&lt;/td&gt;
&lt;td&gt;263&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Breadth-First Search&lt;/td&gt;
&lt;td&gt;260&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Heap (Priority Queue)&lt;/td&gt;
&lt;td&gt;222&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Graph&lt;/td&gt;
&lt;td&gt;190&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stack&lt;/td&gt;
&lt;td&gt;182&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sliding Window&lt;/td&gt;
&lt;td&gt;175&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backtracking&lt;/td&gt;
&lt;td&gt;114&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Union Find&lt;/td&gt;
&lt;td&gt;98&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Three things follow from this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Array, String, and Hash Table are not patterns, they are the surface.&lt;/strong&gt; They head the list because almost everything is phrased in terms of them. What matters is the technique applied to them, which is why Two Pointers and Sliding Window carry so much weight despite smaller tag counts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A small set of patterns covers most of the volume.&lt;/strong&gt; Two Pointers, Sliding Window, Modified Binary Search, the two tree traversals, and Dynamic Programming together account for more tagged problems than the rest of this list combined. If your preparation time is short, those are the ones to install first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The long tail is still worth knowing, but last.&lt;/strong&gt; K-way Merge has 17 tagged problems and Multi-threaded has 9. They are rare, and they are also the ones candidates most often have no answer for. Learn them when the common patterns are automatic, not before.&lt;/p&gt;

&lt;h2&gt;
  
  
  How This Compares With the Other LeetCode Pattern Lists
&lt;/h2&gt;

&lt;p&gt;Three resources come up whenever people look for this, and they are all worth knowing about. They do different jobs, and two of them are free.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sean Prashad's Leetcode Patterns
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://seanprashad.com/leetcode-patterns/" rel="noopener noreferrer"&gt;seanprashad.com/leetcode-patterns&lt;/a&gt; is a free, open source list, and it is the most widely used of the three. Its repository describes it as "a pattern-based approach to learn technical interview questions" and carries 14,117 stars.&lt;/p&gt;

&lt;p&gt;What it gives you is a curated set of &lt;strong&gt;179 problems&lt;/strong&gt; you can filter by difficulty, by company, and by pattern, plus a condition-to-approach table that maps a problem characteristic to a suggested technique. It is excellent for deciding what to solve next, and for working a company-specific list before an onsite.&lt;/p&gt;

&lt;p&gt;What it does not do is teach the patterns. The labels it sorts by are mostly LeetCode's own topic tags, around 75 of them, so "Array" and "Hash Table" sit alongside "Sliding Window". If you already know the patterns, that is exactly what you want. If you are trying to learn them, a list cannot explain why a window contracts or when binary search applies to an answer rather than an array.&lt;/p&gt;

&lt;h3&gt;
  
  
  AlgoMaster's 15 Patterns
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://blog.algomaster.io/p/15-leetcode-patterns" rel="noopener noreferrer"&gt;AlgoMaster's post&lt;/a&gt; covers 15 patterns, each with a diagram, a one-line note on when to use it, and three linked LeetCode problems. It is well made and it is the piece most people have read on this topic.&lt;/p&gt;

&lt;p&gt;It stops short of code. There is no template for any of the 15, so you get the idea of a pattern without the implementation you would actually write under time pressure.&lt;/p&gt;

&lt;h3&gt;
  
  
  NeetCode
&lt;/h3&gt;

&lt;p&gt;NeetCode is a roadmap built around curated problem lists with solution walkthroughs, and it is the strongest option if you prefer to learn by watching rather than reading. We cover it separately rather than summarize it here: &lt;a href="https://www.grokkingthecodinginterview.com/blog/neetcode-roadmap" rel="noopener noreferrer"&gt;the NeetCode roadmap on one page&lt;/a&gt; maps the pattern behind each topic, and &lt;a href="https://www.grokkingthecodinginterview.com/blog/neetcode-vs-leetcode" rel="noopener noreferrer"&gt;NeetCode compared with LeetCode&lt;/a&gt; puts the numbers side by side.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where this page fits
&lt;/h3&gt;

&lt;p&gt;This one is the explained version. Every pattern gets the cue that identifies it, why the technique works, a template in Python, a diagram, and three problems, so you can go from never having seen a pattern to writing it from memory without leaving the page.&lt;/p&gt;

&lt;p&gt;Use whichever fits what you need right now. If you want a filterable queue of problems, use Sean Prashad's list. If you want video, use NeetCode. If you want to understand the 20 patterns well enough to recognize them on a question you have never seen, read this page and then practice against one of those lists. They work well together, and a free list plus a real explanation beats either on its own.&lt;/p&gt;

&lt;p&gt;For a wider view of the paid and free options, including the video courses, see &lt;a href="https://www.grokkingthecodinginterview.com/blog/best-dsa-courses" rel="noopener noreferrer"&gt;the best DSA courses compared&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Use This List
&lt;/h2&gt;

&lt;p&gt;Work one pattern at a time rather than one problem at a time. Read the cue, write the template from memory, then solve the three linked problems in a row. Practicing LeetCode problems pattern wise, meaning grouped by the pattern that solves them rather than in list order, teaches you more than solving ten unrelated ones, because the third problem in a group is where recognition starts to happen on its own.&lt;/p&gt;

&lt;p&gt;That is why the 60 problems on this page are grouped under their pattern instead of being given as one flat list. A flat list trains you to grind. Problems grouped by pattern train you to recognize.&lt;/p&gt;

&lt;p&gt;When a problem defeats you, do not jump straight to the solution. Ask which of these 20 it resembles first. If you can name the pattern and still cannot finish, that is a template problem and it is quick to fix. If you cannot name the pattern at all, that is the skill actually being tested, and it is the one worth practicing.&lt;/p&gt;

&lt;p&gt;The full curriculum, with each pattern taught in six languages and grouped practice problems, is in &lt;a href="https://www.designgurus.io/course/grokking-the-coding-interview?utm_source=devto" rel="noopener noreferrer"&gt;Grokking the Coding Interview&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Check out &lt;a href="https://www.designgurus.io/blind75?utm_source=devto" rel="noopener noreferrer"&gt;Blind75&lt;/a&gt; for more problems. If you are choosing a course to learn these patterns from, &lt;a href="https://www.grokkingthecodinginterview.com/blog/best-dsa-courses" rel="noopener noreferrer"&gt;The Best DSA Courses Compared: Paid, Free, and YouTube&lt;/a&gt; reviews the main options side by side.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQs - LeetCode Patterns and Interview Prep
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Q1. What are LeetCode patterns?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;LeetCode patterns&lt;/strong&gt; are common coding techniques or strategies that repeatedly show up in LeetCode problems and technical interviews. Instead of solving every problem from scratch, learning these patterns helps you recognize how to approach and solve new problems based on familiar logic (e.g., Two Pointers, Sliding Window, DFS, etc.).&lt;/p&gt;

&lt;h3&gt;
  
  
  Q2. Why should I learn LeetCode patterns instead of solving random problems?
&lt;/h3&gt;

&lt;p&gt;Focusing on patterns helps you avoid burnout and prepares you faster. Each pattern unlocks the ability to solve dozens of problems, which is much more efficient than solving 500+ random questions without structure. Interviewers often test your ability to apply known patterns to new scenarios, not just memorize solutions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q3. How many LeetCode patterns should I learn for FAANG interviews?
&lt;/h3&gt;

&lt;p&gt;Learn all &lt;strong&gt;20&lt;/strong&gt;, in the order on this page. The first six, Two Pointers, Sliding Window, Modified Binary Search, the two tree traversals, and Dynamic Programming, cover the largest share of what gets asked, so start there if your time is short. The remaining fourteen are what separate a candidate who handles the common question from one who is not stopped by an unusual one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q4. Do LeetCode patterns actually help in real interviews?
&lt;/h3&gt;

&lt;p&gt;Yes, most FAANG interview questions map to well-known patterns. Recognizing the right pattern during an interview helps you solve problems faster and with more confidence, especially under time pressure. It also shows your structured thinking, which is exactly what interviewers want.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q5. Where can I practice LeetCode patterns?
&lt;/h3&gt;

&lt;p&gt;You can start with categorized problem lists on LeetCode itself, or check out structured resources like &lt;strong&gt;&lt;a href="https://www.designgurus.io/course/grokking-the-coding-interview?utm_source=devto" rel="noopener noreferrer"&gt;Grokking the Coding Interview&lt;/a&gt;&lt;/strong&gt;, which teaches these patterns with guided explanations and practice problems grouped by pattern.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q6. Are LeetCode patterns the same as algorithms?
&lt;/h3&gt;

&lt;p&gt;Not exactly. Algorithms are step-by-step procedures for solving specific types of problems (like Dijkstra’s or Merge Sort). &lt;strong&gt;Patterns&lt;/strong&gt; are reusable problem-solving approaches, like frameworks, that help you decide &lt;em&gt;how&lt;/em&gt; to apply different algorithms or data structures depending on the question.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q7. How do I identify which pattern a question belongs to?
&lt;/h3&gt;

&lt;p&gt;Look at the problem constraints and the goal. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Need to find a subarray or substring? → Try &lt;strong&gt;Sliding Window&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Working with sorted data or binary decisions? → Use &lt;strong&gt;Binary Search&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Need to explore all paths or combinations? → Think &lt;strong&gt;DFS&lt;/strong&gt; or &lt;strong&gt;Backtracking&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The more patterns you practice, the easier it becomes to recognize which one fits.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q8. Is mastering patterns enough to crack coding interviews?
&lt;/h3&gt;

&lt;p&gt;Patterns are your foundation, but combine them with good communication, mock interviews, and time management. You should also review system design (for senior roles), &lt;a href="https://www.designgurus.io/blog/tech-interview-behavioral-questions?utm_source=devto" rel="noopener noreferrer"&gt;behavioral interview questions&lt;/a&gt;, and understand the company’s specific process.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q9. What are the best LeetCode patterns to know?
&lt;/h3&gt;

&lt;p&gt;The best LeetCode patterns to focus on are the ones that appear most frequently in coding interviews and help solve a wide variety of problems. These include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Two Pointers&lt;/strong&gt; – great for arrays and strings&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sliding Window&lt;/strong&gt; – ideal for subarray/substring problems&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Depth-First Search (DFS)&lt;/strong&gt; – for tree and graph traversal&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Breadth-First Search (BFS)&lt;/strong&gt; – used in shortest path and level order problems&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Binary Search&lt;/strong&gt; – for problems with sorted data or monotonic conditions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Merge Intervals&lt;/strong&gt; – useful in scheduling and overlapping intervals&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic Programming (DP)&lt;/strong&gt; – for optimization and counting problems&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recursion &amp;amp; Backtracking&lt;/strong&gt; – perfect for exhaustive search and decision trees&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monotonic Stack&lt;/strong&gt; – for next greater/smaller element problems&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Union-Find (DSU)&lt;/strong&gt; – for detecting cycles and grouping connected components&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mastering these patterns allows you to recognize problem types quickly and apply efficient solutions, critical for success in FAANG interviews.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q10. Why study coding patterns for interviews?
&lt;/h3&gt;

&lt;p&gt;Studying coding patterns helps you avoid random practice and prepare more strategically. Instead of solving every problem from scratch, patterns teach you how to &lt;strong&gt;recognize the underlying structure&lt;/strong&gt; of a problem and &lt;strong&gt;reuse proven techniques&lt;/strong&gt;. This saves time, builds confidence, and dramatically improves your problem-solving skills.&lt;/p&gt;

&lt;p&gt;Most interview problems are variations of core patterns. &lt;/p&gt;

&lt;p&gt;By mastering them, you’ll be able to tackle new problems more quickly, reduce anxiety during live interviews, and demonstrate structured thinking, something interviewers love to see. In short, patterns are the shortcut to smarter and faster coding interview prep.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Go deeper:&lt;/strong&gt; for the expanded version of this pattern-first approach, see the &lt;a href="https://www.grokkingthecodinginterview.com/blog/leetcode-patterns" rel="noopener noreferrer"&gt;complete guide to all 42 coding interview patterns&lt;/a&gt;, which includes the tell that identifies each pattern from the problem statement, a printable cheat sheet, and free pattern-by-pattern deep dives.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q11. How many LeetCode patterns are there?
&lt;/h3&gt;

&lt;p&gt;There is no official count, because LeetCode does not publish one. This guide uses &lt;strong&gt;20&lt;/strong&gt;, which is the set that covers the overwhelming majority of interview questions without padding the list. Other lists quote 14, 15, or 23; the differences are mostly about whether closely related techniques are split apart or grouped together, not about the underlying ideas.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q12. Are LeetCode patterns the same as design patterns or pattern matching?
&lt;/h3&gt;

&lt;p&gt;No, and the three get confused often.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Design patterns&lt;/strong&gt; are object-oriented structures such as Singleton, Factory, and Observer. They belong to object-oriented design and low level design rounds, not to the algorithmic patterns on this page. LeetCode does have a separate &lt;strong&gt;Design&lt;/strong&gt; tag, with 134 problems like LRU Cache and Design Twitter, which asks you to build a data structure to a specification. That is a different skill again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pattern matching&lt;/strong&gt; means string matching, regular expressions, and problems like Regular Expression Matching or Wildcard Matching. It is a problem topic, not a solving strategy.&lt;/p&gt;

&lt;p&gt;The 20 on this page are &lt;strong&gt;coding patterns&lt;/strong&gt;, also called DSA patterns: reusable strategies for recognizing and solving algorithm questions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related questions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/answers/detail/which-is-better-codechef-or-leetcode-or-hackerrank"&gt;Which is better CodeChef or LeetCode or HackerRank?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/answers/detail/how-many-leetcode-problems-should-i-do-per-day"&gt;How many LeetCode problems should I do per day?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/answers/detail/what-is-a-good-rank-on-leetcode"&gt;What is a good rank on LeetCode?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/answers/detail/how-much-leetcode-is-enough-for-google"&gt;How much LeetCode is enough for Google?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/answers/detail/do-faang-companies-ask-leetcode-hard"&gt;Do Faang companies ask LeetCode hard?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/answers/detail/what-is-a-good-acceptance-rate-on-leetcode"&gt;What is a good acceptance rate on LeetCode?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/answers/detail/what-is-the-most-used-language-on-leetcode"&gt;What is the most used language on LeetCode?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://www.designgurus.io/blog/top-lc-patterns?utm_source=devto" rel="noopener noreferrer"&gt;DesignGurus.io&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>leetcode</category>
      <category>algorithms</category>
      <category>interview</category>
      <category>programming</category>
    </item>
    <item>
      <title>System Design Patterns: The Complete Guide (60+ Patterns Explained Simply)</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Sun, 19 Jul 2026 06:41:18 +0000</pubDate>
      <link>https://dev.to/arslan_ah/system-design-patterns-the-complete-guide-60-patterns-explained-simply-1ckk</link>
      <guid>https://dev.to/arslan_ah/system-design-patterns-the-complete-guide-60-patterns-explained-simply-1ckk</guid>
      <description>&lt;p&gt;Every system you admire is built from parts you can name. The feed that loads in 80 milliseconds, the checkout that survives a datacenter failure, the chatbot that answers from yesterday's documentation: each one is a composition of the same recurring solutions, applied in the right places. Those recurring solutions are &lt;strong&gt;system design patterns&lt;/strong&gt;, and there are roughly sixty of them worth knowing.&lt;/p&gt;

&lt;p&gt;This guide covers all of them. For each pattern you will get three things: the problem it solves, the core move it makes, and the price you pay for using it. By the end, you should be able to look at any architecture, or any interview prompt, and see the parts.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. What Are System Design Patterns?
&lt;/h2&gt;

&lt;p&gt;A system design pattern is a named, reusable solution to a problem that recurs when you build distributed systems. "Reads are overwhelming my database" is a recurring problem; &lt;strong&gt;primary-replica replication&lt;/strong&gt; is its named solution. "A retry charged the customer twice" is a recurring problem; &lt;strong&gt;idempotency&lt;/strong&gt; is its named solution.&lt;/p&gt;

&lt;p&gt;Two clarifications before we start.&lt;/p&gt;

&lt;p&gt;First, system design patterns are not the same as the classic "design patterns" from the Gang of Four book. Those are code-level patterns (Singleton, Observer, Factory) for organizing classes inside one program. System design patterns are architecture-level: they describe how databases, queues, caches, and services work together across many machines. In a system design interview, the interviewer means the architecture-level kind.&lt;/p&gt;

&lt;p&gt;Second, a pattern is not a technology. Kafka is a product; the &lt;strong&gt;message queue&lt;/strong&gt; and the &lt;strong&gt;append-only log&lt;/strong&gt; are the patterns inside it. Redis is a product; &lt;strong&gt;cache-aside&lt;/strong&gt; is the pattern you use it for. Learn the pattern and you can evaluate any product. Learn only the product and you are lost when the stack changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Why Patterns Beat Memorizing Architectures
&lt;/h2&gt;

&lt;p&gt;There are thousands of possible system designs, and you cannot memorize them all. You do not need to. Architectures are sentences; patterns are the words. Once you own the vocabulary, "design Instagram" stops being a memory test and becomes a composition exercise.&lt;/p&gt;

&lt;p&gt;Working with patterns is three habits:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Diagnosis.&lt;/strong&gt; Recognize which problem you are actually looking at. Dashboards are green but one feature is starving: that is the bulkhead problem. Two teams' metrics disagree: that is the same question with two authors. Most of system design skill is matching symptoms to shapes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Composition.&lt;/strong&gt; Combine patterns, and handle the seams between them. Retries demand idempotency. Caches demand a stampede plan. Sagas demand designed compensations. The seams are where real engineering lives.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pricing.&lt;/strong&gt; Every pattern is a purchase. Sharding buys write scale and costs you cross-shard queries. Caching buys speed and costs you staleness. Saying the cost out loud, in the same breath as the pattern, is what separates senior answers from buzzword answers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Keep those three habits in mind as you read the catalog below. Each entry is deliberately structured as diagnosis (the problem), composition material (the move), and price (the cost).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(I teach all sixty of these patterns in depth, each one through a real production incident, in my course &lt;a href="https://www.designgurus.io/course/system-design-patterns?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=sdp-cluster&amp;amp;utm_content=system-design-patterns-complete-guide" rel="noopener noreferrer"&gt;System Design Patterns: From Fundamentals to Real Systems&lt;/a&gt;. This guide is the map; the course is the territory.)&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. The Complete List: 60+ System Design Patterns by Category
&lt;/h2&gt;

&lt;p&gt;The patterns fall into ten categories. Use the list below to jump around, or read straight through: the order follows how problems actually arrive as a system grows.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Communication patterns (7)&lt;/li&gt;
&lt;li&gt;Storage and replication patterns (6)&lt;/li&gt;
&lt;li&gt;Caching patterns (5)&lt;/li&gt;
&lt;li&gt;Reliability patterns (7)&lt;/li&gt;
&lt;li&gt;Scaling patterns (5)&lt;/li&gt;
&lt;li&gt;Consistency patterns (4)&lt;/li&gt;
&lt;li&gt;API and edge patterns (9)&lt;/li&gt;
&lt;li&gt;Operations and delivery patterns (5)&lt;/li&gt;
&lt;li&gt;Data-intensive patterns (7)&lt;/li&gt;
&lt;li&gt;AI-era patterns (7)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fktifelms1rsc0n9zmr9h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fktifelms1rsc0n9zmr9h.png" alt="The System Design Pattern Map: 60+ patterns in ten categories" width="799" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Communication Patterns: Moving Data Between Services
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Request-Response.&lt;/strong&gt; The default: a client asks, a server answers, someone waits. It is the right choice whenever a user is waiting for the answer. Its weakness is coupling: the caller's fate is tied to the callee's speed and health, which is why half the reliability patterns below exist.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Message Queue.&lt;/strong&gt; Work that nobody needs to wait on goes into a queue, and workers process it at their own pace. Traffic spikes become backlog instead of outages. The price: delivery is at-least-once, so consumers must handle duplicates, and the queue's depth becomes a metric you must watch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Publish-Subscribe.&lt;/strong&gt; One event, many independent consumers. The order service announces "order placed" once; email, analytics, and inventory each react without knowing about each other. The price: your event schema becomes a public contract, and changing it becomes a negotiation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Event-Driven Architecture.&lt;/strong&gt; The pub-sub idea promoted to an architectural style: services react to facts instead of calling each other. You gain loose coupling and independent scaling. You pay in governance: who consumes what, and how a business flow is traced across five reacting services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Webhooks.&lt;/strong&gt; Events delivered across company boundaries as HTTP POSTs. The receiving discipline: verify the signature, save the raw event, respond in milliseconds, process later behind your own queue, and reconcile with a polling loop, because the worst webhook failure looks exactly like a quiet day.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Server-Sent Events (SSE).&lt;/strong&gt; One HTTP response that never ends: the server pushes updates down it as they happen. It is why LLM chat apps show words one at a time. One direction only, and the browser handles reconnection for you. When the client needs to talk back continuously, you have outgrown it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bidirectional Streaming (WebSockets).&lt;/strong&gt; A true two-way conversation on one connection: chat, collaborative editing, multiplayer games. The price is stateful, sticky connections and reconnection logic you now own. The rule: escalate to it on need, never on fashion.&lt;/p&gt;

&lt;h3&gt;
  
  
  Storage and Replication Patterns: Where Truth Lives
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Primary-Replica Replication.&lt;/strong&gt; One machine takes all writes and streams its change log to replicas that serve reads. Read capacity scales by adding copies, and a dead primary is replaced by promoting a replica. The price: replicas lag slightly, so a user can miss their own write, and replicas add zero write capacity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sharding.&lt;/strong&gt; When writes or data size outgrow one machine, split the table's rows across machines by a shard key. The key is the whole game: it should appear in nearly every query, spread load evenly, and keep related rows together. The price: cross-shard queries, cross-shard transactions, and hot keys become your problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consistent Hashing.&lt;/strong&gt; The routing rule that lets a cluster change size gracefully. With naive modulo routing, adding a fifth shard moves 80% of all data. On the hash ring, it moves about 20%: only the slice the new server takes over. Virtual nodes keep the slices even and spread a dead server's load across everyone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Write-Ahead Log (WAL).&lt;/strong&gt; Before touching any data structure, the database appends one record describing the change to a log and forces it to disk. Only then does it say "saved." Crash recovery is replaying the log. This one mechanism also powers replication and point-in-time recovery, which makes the append-only log the most important structure in the database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Event Sourcing.&lt;/strong&gt; Store what happened, not what is. Every change is an immutable business event (OrderPlaced, OrderCancelled), and current state is derived by replaying them. Perfect audit trails and time travel, at the cost of projections for queries and event schemas that live forever. The default answer is no; the exception is ledger-shaped domains: money, orders, inventory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CQRS.&lt;/strong&gt; When reads and writes want different shapes, split the model: a lean, validated write model, and read models shaped for each question (a pre-joined table, a search index, an aggregates store), kept in sync from a change stream. Never sync them by writing to both from application code: dual writes drift silently.&lt;/p&gt;

&lt;h3&gt;
  
  
  Caching Patterns: Serving Data Fast
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Cache-Aside.&lt;/strong&gt; The default cache: the application checks the cache, loads from the database on a miss, and stores the result. Two numbers rule everything: the hit ratio and the staleness budget. Invalidation is your job, and the TTL is your safety net.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Read-Through.&lt;/strong&gt; The cache itself loads misses from the database, so application code just reads. Cleaner call sites, at the cost of a smarter cache layer in your read path.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Write-Through.&lt;/strong&gt; Writes go to the cache and the store together, so reads are always warm and never stale. The price: every write pays for both.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Write-Behind.&lt;/strong&gt; Writes land in the cache and flush to the store later, in batches. Enormous write throughput, with a window where acknowledged data exists only in memory. Never for money.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cache Stampede Prevention.&lt;/strong&gt; When a popular key expires, a thousand requests can miss at once and crush the database together. The cures: let one request rebuild while others wait (single flight), add jitter to expiry times, and refresh hot keys before they expire.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reliability Patterns: Surviving Failure
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Timeout.&lt;/strong&gt; No wait is allowed to be unbounded. Every network call gets a deadline, chosen from the callee's real latency profile. The subtlety: a timeout means "I stopped waiting," never "it did not happen." The work may have finished after you gave up, which is why idempotency exists.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Retry with Exponential Backoff.&lt;/strong&gt; Transient failures deserve a second try, with increasing delays and randomness (jitter) so a thousand clients do not retry in lockstep and finish off a struggling server. Retries without backoff, jitter, and a budget are how outages get worse.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Idempotency.&lt;/strong&gt; The same request processed twice must have the effect of once. The client generates a unique key per operation, and the server remembers keys it has seen. This is the pattern that makes retries safe, and the reason a double-clicked "Pay" button charges once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Circuit Breaker.&lt;/strong&gt; When a dependency keeps failing, stop calling it. Fail fast, give it time to recover, and probe occasionally to see if it is back. This turns a slow, cascading failure into a fast, contained one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bulkhead.&lt;/strong&gt; Partition your resources so one workload cannot starve the rest. Separate connection pools, thread pools, or fleets per feature. The symptom it prevents: dashboards green overall while one feature quietly consumed every thread.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dead Letter Queue.&lt;/strong&gt; A message that fails repeatedly gets moved aside into a quarantine queue, so it stops blocking everything behind it. The DLQ needs an owner and an alert, or it becomes a place where problems go to be forgotten.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Graceful Degradation.&lt;/strong&gt; Decide in advance what each feature does when its dependencies fail: serve stale data, show a smaller answer, or refuse. Availability features fail open; money and authorization fail closed. The worst answer is the one nobody designed: a blank error page.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scaling Patterns: Growing Under Load
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Vertical Scaling.&lt;/strong&gt; A bigger machine. No new failure modes, no code changes, and it buys you time. It has a ceiling, and at the top of the catalog the prices climb steeply. Exhaust the simple win before taking on distributed problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Horizontal Scaling.&lt;/strong&gt; Many identical, stateless copies behind a load balancer. The catch is the word stateless: sessions, counters, and files must move out of the server first, or each copy holds a different fraction of the truth.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Load Balancing.&lt;/strong&gt; Spreading requests across those copies, informed by health checks and actual load. Draining connections before removing a server is the difference between a deploy and an incident.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Auto-Scaling.&lt;/strong&gt; Capacity that follows demand: scheduled scaling for the load you can predict (most of it), reactive scaling for the surprise. Reaction takes minutes, so headroom is part of the design, and the maximum is a safety limit you set on purpose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connection Pooling.&lt;/strong&gt; Opening a database connection is expensive; reuse a small pool of warm ones instead. The quiet trap: pool size multiplies across your fleet, and 50 servers with modest pools can exhaust a database's connection limit.&lt;/p&gt;

&lt;h3&gt;
  
  
  Consistency Patterns: Keeping Data Correct Across Machines
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Two-Phase Commit (2PC).&lt;/strong&gt; The coordinator asks all participants to prepare, then tells them all to commit: atomicity across machines. The price: everyone blocks if the coordinator dies at the wrong moment. It works inside one trust boundary; it does not cross companies. Often the best move is designing the transaction away entirely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Saga.&lt;/strong&gt; A long business transaction as a sequence of local steps, each with a designed compensation (undo) if a later step fails. Book the flight, book the hotel; if the hotel fails, unbook the flight. Order the irreversible steps last. This is how money moves between systems that share no database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quorum.&lt;/strong&gt; Decisions by majority: with three or five copies, require agreement from more than half before an answer counts. Majorities prevent split brain, because two disagreeing majorities cannot exist. The price is latency, and a minority partition that goes read-only on purpose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vector Clocks.&lt;/strong&gt; A way to track causality so the system can tell "this edit came after that one" apart from "these two edits happened concurrently and neither saw the other." Concurrent edits become explicit conflicts to resolve rather than silent overwrites.&lt;/p&gt;

&lt;h3&gt;
  
  
  API and Edge Patterns: The Front Door
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Reverse Proxy.&lt;/strong&gt; One front door for your servers: it terminates TLS, routes requests, and shields the fleet behind it. Nearly every pattern in this category is a specialized reverse proxy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CDN.&lt;/strong&gt; Copies of your content cached at the edge, near users. The two disciplines: getting invalidation right, and never letting private, per-user responses into a shared cache.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API Gateway.&lt;/strong&gt; Cross-cutting policy enforced once: authentication, rate limits, routing to services. The discipline is staying thin. The moment business logic moves in, you have rebuilt the monolith in the doorway.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Backend for Frontend (BFF).&lt;/strong&gt; A thin backend per client type (web, mobile) that composes reads into exactly the shape that client needs. Presentation composes reads; the domain services keep owning writes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rate Limiting.&lt;/strong&gt; Protecting capacity by refusing excess politely: token buckets that allow bursts but cap sustained rates, tiered by customer. A 429 with a Retry-After header is a feature, not a failure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cursor-Based Pagination.&lt;/strong&gt; Page through data by position ("after item X") instead of offset ("items 51-100"), so results stay stable while new data arrives. The price: no jumping to page seven.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API Versioning.&lt;/strong&gt; Changing an API without breaking its clients: additive changes where possible, versioned contracts where not. Every field you publish is a promise someone will hold you to for years.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sidecar.&lt;/strong&gt; Cross-cutting concerns (TLS, retries, telemetry) packaged as a helper process that runs beside every service instance, in any language. The building block that makes the next pattern possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Service Mesh.&lt;/strong&gt; Sidecars on every service plus a control plane: mutual TLS, retries, timeouts, and telemetry for all service-to-service traffic, without touching application code. A heavy platform. Adopt it when the service count and compliance needs clear the bar, not before.&lt;/p&gt;

&lt;h3&gt;
  
  
  Operations and Delivery Patterns: Shipping Without Breaking
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Health Check Endpoint.&lt;/strong&gt; The difference between "the process is running" (liveness) and "the process can do useful work" (readiness), exposed as endpoints that load balancers and deploys consult. Shallow checks lie; check the dependencies that matter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Distributed Tracing.&lt;/strong&gt; One request's story across every service it touched, stitched together by a trace ID. When the checkout is slow, the trace shows which of the nine hops ate the time. Instrumentation costs effort; debugging without it costs more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blue-Green Deployment.&lt;/strong&gt; Two identical environments; switch traffic instantly, switch back instantly if something breaks. The catch everyone learns once: the database does not blue-green. Schema changes need the expand-contract discipline.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Canary Deployment.&lt;/strong&gt; Release to a small slice first, judge it against the current version on real metrics, then widen. The judging is the pattern: a canary without honest verdict metrics is theater.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Feature Flags.&lt;/strong&gt; Separate deploying code from releasing behavior. The code ships dark; the behavior turns on with a flag, per cohort, reversible in seconds. The debt: flags must be deleted after they win, or the codebase fills with dead switches.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data-Intensive Patterns: Batch and Streaming
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;MapReduce.&lt;/strong&gt; The batch shape: process a huge dataset by working on pieces in parallel where the data lives (map), regrouping by key (shuffle), and merging (reduce). You will never write raw MapReduce, and you will never escape its shape: it is the physics under every warehouse and Spark job.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stream Processing.&lt;/strong&gt; A job that runs forever, holding running counts keyed by the thing being watched, answering while the data is still arriving. Its hard ideas: event time versus arrival time, watermarks that decide when a window may close, and answers that may be amended when stragglers arrive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lambda and Kappa Architectures.&lt;/strong&gt; Two answers to batch and streaming both computing the same numbers. Lambda runs both, with batch overwriting the stream's results on schedule. Kappa keeps one streaming codebase over a replayable log and re-runs history when logic changes. The rule either way: every metric gets exactly one definition of truth.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Change Data Capture (CDC).&lt;/strong&gt; Tail the database's own write-ahead log and publish every committed change as an event. It cannot miss: bulk imports and manual fixes flow through the same log as app writes. This is how search indexes, caches, and warehouses stay in sync without fragile dual writes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exactly-Once Semantics.&lt;/strong&gt; Counting things once despite crashes and retries. Delivery can never be exactly-once; the effect can be, by moving the processing state and the outputs together with the log position. Reserve the heavy machinery for numbers with auditors: billing, ledgers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Backpressure.&lt;/strong&gt; When a producer outruns a consumer, something must give: a bounded buffer absorbs bursts, a drop policy sheds what is worthless when stale, or the producer is slowed. The one wrong answer is the unbounded buffer, which schedules an out-of-memory crash instead of surfacing the mismatch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Partitioned Consumption.&lt;/strong&gt; Order per key, parallelism across keys: every event for a given customer lands in the same partition, each partition has exactly one consumer, so a refund can never be processed before its charge. The partition count is a ceiling chosen in advance, and one hot key can still make one partition burn.&lt;/p&gt;

&lt;h3&gt;
  
  
  AI-Era Patterns: LLM and ML Infrastructure
&lt;/h3&gt;

&lt;p&gt;Nothing in the AI stack is architecturally new; every pattern here is one of the above operating under changed constants. But the changed constants matter enough that these seven deserve their own names.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Feature Store.&lt;/strong&gt; Define each ML feature once, and let a platform compute it both offline for training and online for serving. This kills training/serving skew: the silent bug where a model learns from one definition of a number and gets served another.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Model Serving and Batching.&lt;/strong&gt; At batch-of-one, a GPU serving an LLM runs at single-digit utilization, because each token step streams the whole model's weights to do almost no math. Continuous batching lets dozens of requests share each weight-pass, multiplying throughput 20-30x. It is the difference between a viable AI feature and an absurd bill.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GPU Auto-Scaling.&lt;/strong&gt; Web autoscaling with both dials at 100x: idle GPUs cost a hundred times more, and cold starts take minutes, not seconds. The answers: scale on queue depth (never CPU), keep warm pools as priced insurance, pre-warm on the calendar, and fall back to a smaller model when capacity gaps hit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LLM Gateway.&lt;/strong&gt; One internal door for all model traffic: it holds the provider keys, meters every token against budgets with hard caps, routes logical model names to physical providers, and runs the failover ladder when a provider browns out. The API gateway pattern, pointed outward.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Semantic Caching.&lt;/strong&gt; Forty percent of user questions are rephrasings of known questions, but exact-match caching catches almost none of them. Key the cache by meaning instead: embed the query and match by similarity, with a conservative threshold, because a false hit serves a confidently wrong answer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vector Database Sharding.&lt;/strong&gt; Similarity search breaks normal sharding's best rule: a nearest-neighbor query has no shard key, so the default is asking every shard and merging. The escape: when every query is tenant-scoped, the tenant filter becomes the shard key and single-shard routing returns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RAG Pipeline.&lt;/strong&gt; Knowledge in model weights has no update path, no citations, and no access control. Retrieval-Augmented Generation fixes all three: keep documents in an index that updates in seconds, retrieve only what the asker is permitted to read, and require the model to answer from the retrieved text with citations. The model reasons; the index remembers.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. How Patterns Compose: A News Feed in Ten Patterns
&lt;/h2&gt;

&lt;p&gt;A pattern list becomes useful when you see composition. Take the classic prompt: design a social feed. Watch the patterns snap together.&lt;/p&gt;

&lt;p&gt;Reads outnumber writes about 50 to 1, so the feed is a read-serving problem. Precompute each user's feed at write time and serve it like a &lt;strong&gt;cache&lt;/strong&gt;: this is &lt;strong&gt;CQRS&lt;/strong&gt;, with the feed as a read model. Posting fans out through a &lt;strong&gt;message queue&lt;/strong&gt; with &lt;strong&gt;partitioned consumption&lt;/strong&gt;, fed reliably by an &lt;strong&gt;outbox (CDC)&lt;/strong&gt; so a committed post always reaches the pipeline. The feed store is a &lt;strong&gt;sharded&lt;/strong&gt;, &lt;strong&gt;consistent-hashed&lt;/strong&gt; cluster of lists, evicted and rebuilt like any cache. Celebrities with 50 million followers would break write-time fan-out, so their posts merge at read time from a hot cache with &lt;strong&gt;stampede prevention&lt;/strong&gt;. Fan-out workers &lt;strong&gt;auto-scale&lt;/strong&gt; on backlog age. Appends are &lt;strong&gt;idempotent&lt;/strong&gt; so at-least-once delivery cannot duplicate a post. When parts fail, the feed &lt;strong&gt;degrades gracefully&lt;/strong&gt;: slightly stale beats blank.&lt;/p&gt;

&lt;p&gt;Ten-plus patterns, one design, and every choice justified by a number or a failure mode. That is what interviewers mean when they say a candidate "thinks in systems." It is also the skill this entire catalog exists to build: not knowing sixty definitions, but composing the right eight of them under pressure.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. How to Learn These Patterns Properly
&lt;/h2&gt;

&lt;p&gt;Reading a list is recognition. Interviews and production require recall and application. Three suggestions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Learn each pattern through its failure story.&lt;/strong&gt; Every pattern above exists because something broke at 2 AM. "Cache stampede prevention" is forgettable; "a thousand requests missed the same expired key at once and crushed the database" is not. Attach each pattern to its incident.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Always learn the price and the "when not."&lt;/strong&gt; A pattern you cannot argue against is a pattern you do not understand. Sharding from day one, CQRS on a settings page, and event sourcing everywhere are the classic ways to pay real complexity for imaginary scale.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice composition on full designs.&lt;/strong&gt; Run the classic prompts (a feed, a ride-sharing dispatch, a payment platform) and force yourself to name every pattern you use and what it costs, out loud.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is exactly how my course, &lt;strong&gt;&lt;a href="https://www.designgurus.io/course/system-design-patterns?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=sdp-cluster&amp;amp;utm_content=system-design-patterns-complete-guide" rel="noopener noreferrer"&gt;System Design Patterns: From Fundamentals to Real Systems&lt;/a&gt;&lt;/strong&gt;, is built. All sixty-plus patterns above get a full lesson: a real production incident, the naive fixes and why they fail, a walkthrough with real numbers, the trade-offs, when NOT to use it, and a 30-second interview answer you can say under pressure. The course ends with four complete interview walkthroughs (a news feed, ride-sharing dispatch, a payment platform, and an AI copilot) where you watch the sixty patterns compose into real systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Frequently Asked Questions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What are system design patterns?&lt;/strong&gt;&lt;br&gt;
System design patterns are named, reusable solutions to problems that recur in distributed systems: scaling reads, surviving failures, keeping data consistent across machines, and moving data between services. They are architecture-level building blocks, used to design systems like feeds, payment platforms, and chat applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How many system design patterns are there?&lt;/strong&gt;&lt;br&gt;
Around sixty patterns cover essentially everything asked in interviews and used in production, spanning communication, storage, caching, reliability, scaling, consistency, APIs, operations, data engineering, and AI infrastructure. This guide lists all of them by category.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Are system design patterns the same as design patterns?&lt;/strong&gt;&lt;br&gt;
No. Classic design patterns (from the Gang of Four book) organize code inside one program: Singleton, Observer, Factory. System design patterns organize infrastructure across many machines: sharding, caching, circuit breakers, sagas. In system design interviews, the interviewer means the architecture-level kind.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which system design patterns matter most for interviews?&lt;/strong&gt;&lt;br&gt;
Eight patterns appear in the overwhelming majority of interview questions: cache-aside, sharding, message queues, circuit breakers, idempotency, sagas, CQRS, and rate limiting. Learn those deeply first, then broaden. The highest-scoring skill is not naming patterns but stating each one's cost as you use it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do AI systems need new system design patterns?&lt;/strong&gt;&lt;br&gt;
Mostly no, and that is good news. The LLM gateway is the API gateway pattern pointed outward, semantic caching is cache-aside with similarity instead of equality, and GPU autoscaling is standard autoscaling with far harsher constants. An engineer who knows the classic sixty walks into AI infrastructure already knowing the building.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Arslan Ahmad is the author of &lt;a href="https://www.designgurus.io/course/grokking-the-system-design-interview" rel="noopener noreferrer"&gt;Grokking the System Design Interview&lt;/a&gt; and founder of DesignGurus.io. His new course, &lt;a href="https://www.designgurus.io/course/system-design-patterns?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=sdp-cluster&amp;amp;utm_content=system-design-patterns-complete-guide" rel="noopener noreferrer"&gt;System Design Patterns: From Fundamentals to Real Systems&lt;/a&gt;, teaches all sixty-plus patterns in this guide through real production incidents.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://www.designgurus.io/blog/system-design-patterns-complete-guide" rel="noopener noreferrer"&gt;DesignGurus.io&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>architecture</category>
      <category>programming</category>
      <category>interview</category>
    </item>
    <item>
      <title>I've taught system design to hundreds of engineers. Here's where I tell them all to start.</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Sat, 04 Jul 2026 03:54:11 +0000</pubDate>
      <link>https://dev.to/arslan_ah/ive-taught-system-design-to-hundreds-of-engineers-heres-where-i-tell-them-all-to-start-3p7g</link>
      <guid>https://dev.to/arslan_ah/ive-taught-system-design-to-hundreds-of-engineers-heres-where-i-tell-them-all-to-start-3p7g</guid>
      <description>&lt;p&gt;Somewhere around the hundredth engineer I coached, I noticed something. Nobody was struggling with system design because it was too hard. They were struggling because they started in the wrong place.&lt;/p&gt;

&lt;p&gt;The pattern was always the same. A smart engineer with two or three years of experience decides it's time to learn system design. They search YouTube, land on "Design Instagram in 45 minutes," and watch someone draw fifteen boxes connected by arrows. They understand maybe four of the boxes. They finish the video feeling like they learned something, try to design anything on their own, and produce a server, a database, and silence.&lt;/p&gt;

&lt;p&gt;Then they conclude system design is a genius-only club, and they either give up or start memorizing diagrams.&lt;/p&gt;

&lt;p&gt;If that's you, nothing is wrong with you. You just entered the building through the roof.&lt;/p&gt;

&lt;h2&gt;
  
  
  The lie that keeps beginners stuck
&lt;/h2&gt;

&lt;p&gt;Here's what I wish someone had told me when I was coming up through Microsoft and Facebook: &lt;strong&gt;system design is not as big as it looks.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It looks infinite because content about it has no agreed-upon sequence. Every blog post assumes you already know whatever the last blog post covered. Every video introduces five terms it never defines. There's no "chapter one" anywhere on the front page of Google.&lt;/p&gt;

&lt;p&gt;But strip the noise away and the field that matters for interviews and for real engineering work reduces to roughly 12 recurring patterns, combined in different ways. Netflix is not magic. Uber is not magic. They're the same dozen ideas arranged for different constraints.&lt;/p&gt;

&lt;p&gt;You cannot see that from the roof. You can only see it from the foundation.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 5 concepts I make everyone learn first
&lt;/h2&gt;

&lt;p&gt;When someone asks me where to start, I give them the same assignment every time: learn these five things, and don't touch a case study until you can explain each one to a non-engineer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The client-server model.&lt;/strong&gt; A client asks, a server answers. Every system you will ever design begins with "the client sends a request to our API server." If this sentence isn't boring and obvious to you yet, everything downstream will feel like fog.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Databases.&lt;/strong&gt; Where data lives when the power goes out. You need exactly one distinction at this stage: SQL databases are structured and relational, NoSQL databases are flexible and easier to scale horizontally. That's it. Do not fall down the "PostgreSQL vs Cassandra vs DynamoDB" rabbit hole in week one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. APIs.&lt;/strong&gt; The contracts that let pieces of software talk to each other without knowing each other's internals. In a design discussion, APIs are the seams of your architecture: where you cut, and where things can change independently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Load balancing.&lt;/strong&gt; One server can't handle a million users, so you run fifty servers, and something has to decide which request goes where. That something is a load balancer, and it appears in every design answer you will ever give. Think of a restaurant hostess distributing guests across tables so no waiter drowns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Caching.&lt;/strong&gt; Databases are slow compared to memory. If a million people request the same homepage feed, computing it a million times is waste. Store the answer once in RAM, serve it a million times in microseconds. Most of "making systems fast" is some version of this idea.&lt;/p&gt;

&lt;p&gt;That's the whole first week. Five concepts. Engineers are usually suspicious of how small this list is, and then a month later they tell me it's the reason the rest finally made sense.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this order beats the "just watch case studies" approach
&lt;/h2&gt;

&lt;p&gt;Case studies are the best part of learning system design. They're also nearly worthless if you do them first.&lt;/p&gt;

&lt;p&gt;When you watch "Design a URL Shortener" without knowing the building blocks, you're memorizing a specific answer. When the constraints change ("what if reads are 100x writes?"), the memorized answer shatters, because you never knew &lt;em&gt;why&lt;/em&gt; the cache was there in the first place.&lt;/p&gt;

&lt;p&gt;When you do the same case study &lt;em&gt;after&lt;/em&gt; learning the blocks, you're doing something completely different: you're practicing selection. You know what a cache does, so the question becomes "does this system need one, and where?" That's the actual skill interviewers grade. It's also the actual skill your job requires.&lt;/p&gt;

&lt;p&gt;Same video. Same diagram. Entirely different learning outcome, purely based on what you knew walking in.&lt;/p&gt;

&lt;h2&gt;
  
  
  The sequence that works
&lt;/h2&gt;

&lt;p&gt;After the first five concepts, the path I give people looks like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Learn the next 7 building blocks&lt;/strong&gt;: sharding, replication, consistency models, message queues, CDNs, indexing, and back-of-the-envelope estimation. Same rule as before: understand what problem each one solves, skip the depth.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Learn a framework.&lt;/strong&gt; Requirements, estimation, API, data model, high-level architecture, deep dives, trade-offs. In that order, every time. A framework turns "design Twitter" from a blank-whiteboard panic into a sequence of small, answerable questions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Now do case studies.&lt;/strong&gt; Start with the URL shortener, then a chat app, then a news feed. Attempt each one yourself, out loud, for 45 minutes before you look at any solution. The gap between your answer and the reference answer is your personalized curriculum.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice out loud, with a human if possible.&lt;/strong&gt; System design interviews are conversations, not exams. I've seen engineers who knew plenty fail because the first time they'd ever articulated a trade-off verbally was in the actual interview.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Spread over eight weeks at an hour or two a day, this takes someone from "what's a load balancer?" to holding a coherent 45-minute design conversation. I've written the full week-by-week version, with links for every concept, in my &lt;a href="https://www.designgurus.io/blog/system-design-for-beginners" rel="noopener noreferrer"&gt;system design roadmap for beginners&lt;/a&gt; if you want the detailed plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three failure modes to watch for
&lt;/h2&gt;

&lt;p&gt;After enough repetitions, I can predict how someone will get stuck before they start:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The memorizer&lt;/strong&gt; collects architecture diagrams like trading cards and freezes the moment an interviewer changes one constraint. Fix: for every component in a design, force yourself to answer "what breaks if I remove this?"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The roof-jumper&lt;/strong&gt; goes straight to "Design WhatsApp" content and drowns in jargon. Fix: the five concepts above, first, no exceptions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The passive consumer&lt;/strong&gt; watches 30 hours of videos, feels fluent, and can't produce a design from a blank page. Fix: never end a study session without explaining what you learned out loud, to a rubber duck if necessary.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All three failure modes share a root cause: consuming content feels like progress, and applying concepts feels like struggle. The struggle is the part that works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start smaller than feels reasonable
&lt;/h2&gt;

&lt;p&gt;If you take one thing from this post, make it this: the engineers who get good at system design are not the ones who were smarter. They're the ones who started with embarrassingly basic material and actually practiced it, while everyone else skipped ahead and silently churned.&lt;/p&gt;

&lt;p&gt;Client-server. Databases. APIs. Load balancing. Caching. Learn those five this week, explain each one out loud to someone patient, and you'll be ahead of most people grinding case study videos.&lt;/p&gt;

&lt;p&gt;And when you're ready for the structured version of the whole journey, the &lt;a href="https://www.designgurus.io/blog/system-design-for-beginners" rel="noopener noreferrer"&gt;full 8-week roadmap&lt;/a&gt; is free, and my &lt;a href="https://www.designgurus.io/course/grokking-system-design-fundamentals" rel="noopener noreferrer"&gt;System Design Fundamentals&lt;/a&gt; course covers the building-blocks phase in one sequenced curriculum if you'd rather not assemble it yourself.&lt;/p&gt;

&lt;p&gt;You don't need to be a distributed-systems wizard to start. You need chapter one. Now you have it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What tripped you up when you started learning system design? I read every comment.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>beginners</category>
      <category>architecture</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>System Design Fundamentals: The 10 Building Blocks to Learn First</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Thu, 02 Jul 2026 12:57:22 +0000</pubDate>
      <link>https://dev.to/arslan_ah/system-design-fundamentals-the-10-building-blocks-to-learn-first-2754</link>
      <guid>https://dev.to/arslan_ah/system-design-fundamentals-the-10-building-blocks-to-learn-first-2754</guid>
      <description>&lt;p&gt;Most people learn system design backwards. They start by reading how Netflix or Uber is built, memorize the finished architecture, and then freeze the moment they're asked to design something slightly different.&lt;/p&gt;

&lt;p&gt;The fix is to learn the &lt;em&gt;parts&lt;/em&gt; before the &lt;em&gt;whole&lt;/em&gt;. Every large system is assembled from a small set of reusable building blocks. Once you understand each block on its own, designing a full system becomes an exercise in choosing which blocks to combine and why. This post covers the 10 to learn first, in a sensible order, so you have the vocabulary before you attempt your first design. If you want to see where these fit in the bigger picture, here's a structured roadmap to &lt;a href="https://www.designgurus.io/learn-system-design" rel="noopener noreferrer"&gt;learn system design&lt;/a&gt; at your level.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to study each block: solves, costs, when
&lt;/h2&gt;

&lt;p&gt;Do not just memorize what each component &lt;em&gt;is&lt;/em&gt;. For every block, learn three things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What it solves.&lt;/strong&gt; The specific problem that makes you reach for it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What it costs.&lt;/strong&gt; The new problem it introduces (every block adds one).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When to use it.&lt;/strong&gt; The signal in a design that says "now I need this."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That third habit is what separates people who can design real systems from people who can only recite them. Keep those three columns in mind as you read.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Load Balancer
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; A traffic cop that sits in front of multiple servers and spreads incoming requests across them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; A single server can only handle so much. A load balancer lets you run many identical servers and distribute load, which gives you both scale and redundancy (if one server dies, traffic routes to the others).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; It becomes a component you have to make highly available itself, and it forces your servers to be stateless (or you have to deal with sticky sessions).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; The moment you say "one server isn't enough" or "what happens if this server goes down."&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuarnmfttxhmx0aib1hq1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuarnmfttxhmx0aib1hq1.png" alt="Load Balancer" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Caching
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; A fast, temporary store for data you access often, sitting between your app and a slower source (like a database).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; Latency and load. Reading from memory is orders of magnitude faster than hitting a database, and it takes pressure off your data store.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; Staleness. The cached copy can drift from the source of truth, so now you own cache invalidation, famously one of the hard problems in computing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; Read-heavy workloads, or any time the same data is requested over and over.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fiypoupn9xzwnf2k8vb7z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fiypoupn9xzwnf2k8vb7z.png" alt="Caching" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Database Replication
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; Keeping copies of your database on multiple machines, usually one primary (writes) and several replicas (reads).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; Read scalability and availability. You can spread reads across replicas, and if the primary fails, a replica can take over.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; Replication lag. Replicas can be slightly behind the primary, so a user might not immediately see their own write. That's the consistency trade-off.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; When reads vastly outnumber writes, or when you can't afford to lose the database if one machine fails.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Database Sharding
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; Splitting one large database into smaller pieces (shards), each holding a subset of the data, spread across machines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; Write scalability and storage limits. When the data or write volume outgrows a single machine, sharding partitions the load.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; A large jump in complexity. Cross-shard queries get hard, and choosing a bad shard key creates "hot" shards that defeat the whole purpose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; When a single database server can no longer hold your data or absorb your writes, and only then. Replication first, sharding later.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Message Queue
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; A buffer that holds messages so one part of your system can hand off work to another without waiting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; Decoupling and load smoothing. Producers and consumers work at their own pace, and traffic spikes get absorbed by the queue instead of crushing a service.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; Added latency (work is now asynchronous) and new failure modes (duplicate messages, ordering, what happens when the queue backs up).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; When work can happen later rather than instantly (sending emails, processing uploads, generating notifications).&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Consistent Hashing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; A clever way to distribute data across a changing set of servers so that adding or removing a server only moves a small fraction of the data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; The rehashing problem. With naive hashing, adding one server reshuffles almost everything. Consistent hashing keeps that disruption minimal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; Conceptual complexity, and the need for tricks like virtual nodes to keep the distribution even.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; Any time you're distributing data or requests across a cluster whose size changes (caches, sharded stores). I broke this one down step by step in &lt;a href="https://dev.to/arslan_ah/how-to-use-consistent-hashing-in-a-system-design-interview-33ge"&gt;consistent hashing in a system design interview&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. CDN (Content Delivery Network)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; A globally distributed network of servers that cache your static content close to users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; Latency for a global audience. Serving an image or video from a city near the user is far faster than from one origin server across the world.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; Cost, plus cache invalidation again (pushing updates to edge locations takes time).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; When you serve static assets (images, video, JS/CSS) to users spread across regions.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Rate Limiter
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; A guard that caps how many requests a client can make in a given window.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; Abuse and overload. It protects your system from being overwhelmed, whether by malicious traffic, buggy clients, or a single user hammering an endpoint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; You have to store and check counters fast (often in a cache), and you have to decide what to do with rejected requests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; Any public API, login endpoint, or any resource you need to protect from spikes and abuse.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Database Indexing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; A data structure that lets the database find rows without scanning the entire table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; Slow reads. An index turns a full-table scan into a fast lookup, dramatically speeding up queries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; Slower writes (every write must update the index) and extra storage. Over-indexing is a real mistake.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; When a query is slow and it filters or sorts on a specific column. This is often the cheapest performance win available.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Data Modeling
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; Deciding how your data is structured and stored: relational tables versus documents, how entities relate, what you optimize for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it solves:&lt;/strong&gt; Almost everything downstream. The right model makes your common queries easy and fast; the wrong one makes every later decision harder.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it costs:&lt;/strong&gt; Time and foresight up front, and the reality that changing the model later is painful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to reach for it:&lt;/strong&gt; First. Before you pick components, understand your data and its access patterns. This is the foundation the other nine blocks sit on.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the blocks combine
&lt;/h2&gt;

&lt;p&gt;Here's the payoff. Take a simple service and watch the blocks appear as constraints arrive:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start with one server and a database (data modeling).&lt;/li&gt;
&lt;li&gt;Traffic grows, so you add more servers behind a &lt;strong&gt;load balancer&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Reads are slow, so you add a &lt;strong&gt;cache&lt;/strong&gt; and some &lt;strong&gt;indexes&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Reads still outpace one database, so you add &lt;strong&gt;replication&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The data outgrows one machine, so you &lt;strong&gt;shard&lt;/strong&gt; it (using &lt;strong&gt;consistent hashing&lt;/strong&gt;).&lt;/li&gt;
&lt;li&gt;Some work doesn't need to be instant, so you offload it to a &lt;strong&gt;message queue&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Users are global, so static assets move to a &lt;strong&gt;CDN&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The public API needs protection, so you add a &lt;strong&gt;rate limiter&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every block entered the design because a specific problem demanded it, not because a checklist said so. That's exactly how you should reason in a real design.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to learn next
&lt;/h2&gt;

&lt;p&gt;Learn these 10 in roughly the order above (data modeling first, sharding and consistent hashing last, since they're the most advanced). Write your own three-line summary for each: solves, costs, when. Then start composing them into full systems.&lt;/p&gt;

&lt;p&gt;If you're brand new and even the prerequisites feel shaky, start with &lt;a href="https://dev.to/arslan_ah/how-to-learn-system-design-from-scratch-with-no-distributed-systems-experience-1591"&gt;learning system design from scratch&lt;/a&gt;. And when you're ready to see how deep each block should go at your career stage, follow the full path in this &lt;a href="https://dev.to/arslan_ah/how-to-learn-system-design-a-roadmap-by-career-level-3e01"&gt;roadmap by career level&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Master the parts, and the whole stops being intimidating. Every "complex" architecture you've ever admired is just these blocks, combined to answer specific constraints.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>programming</category>
      <category>computerscience</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>How to Learn System Design From Scratch (With No Distributed Systems Experience)</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Tue, 30 Jun 2026 21:24:53 +0000</pubDate>
      <link>https://dev.to/arslan_ah/how-to-learn-system-design-from-scratch-with-no-distributed-systems-experience-1591</link>
      <guid>https://dev.to/arslan_ah/how-to-learn-system-design-from-scratch-with-no-distributed-systems-experience-1591</guid>
      <description>&lt;p&gt;If you have ever opened a system design article, seen a diagram with twelve boxes, three databases, a message queue, and the words "eventually consistent," and quietly closed the tab, this post is for you.&lt;/p&gt;

&lt;p&gt;There is a myth that you need years of experience running large systems before you can learn system design. You don't. Plenty of engineers learn it before they have ever deployed anything bigger than a side project. What you actually need is the right starting point and a way to build intuition without access to production-scale traffic. That is exactly what this guide gives you.&lt;/p&gt;

&lt;h2&gt;
  
  
  "But I've never built anything at scale"
&lt;/h2&gt;

&lt;p&gt;Good news: neither had most people the first time they learned this. System design is not a memory test about how Uber works. It is a &lt;em&gt;thinking&lt;/em&gt; skill: given a vague problem and some constraints, make a sequence of reasonable trade-offs and explain them clearly.&lt;/p&gt;

&lt;p&gt;That skill does not require having operated a system serving millions of users. It requires understanding what the moving parts do and practicing the reasoning. The experience helps later, but it is not the price of entry. So drop the idea that you are "not ready." You are ready to start today.&lt;/p&gt;

&lt;h2&gt;
  
  
  The honest minimum prerequisites
&lt;/h2&gt;

&lt;p&gt;You do not need much, but you do need these four things. If any feels shaky, spend a few days here first; it will save you weeks of confusion later.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;What happens when you load a web page.&lt;/strong&gt; Client sends a request, DNS resolves a name to an address, a server responds. If you can sketch that, you're fine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The two kinds of databases.&lt;/strong&gt; Relational (tables, rows, SQL) versus non-relational (documents, key-value). You don't need to be an expert, just know they exist and roughly when each fits.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What an index is.&lt;/strong&gt; A way to find data fast without scanning everything. That one sentence is enough to begin.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Basic estimation.&lt;/strong&gt; If something gets a million requests a day, roughly how many is that per second? (About 12, for the record.) The ability to do rough math out loud matters more than precision.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Notice what is &lt;em&gt;not&lt;/em&gt; on this list: Kubernetes, Kafka, distributed consensus, the CAP theorem. Beginners reach for those far too early. You will learn them when a problem actually demands them.&lt;/p&gt;

&lt;h2&gt;
  
  
  The mindset shift that unlocks everything
&lt;/h2&gt;

&lt;p&gt;Beginners try to learn system design by collecting answers: how is Instagram's feed built, how does WhatsApp deliver messages, how does YouTube store video. They memorize a dozen "reference architectures" and feel productive.&lt;/p&gt;

&lt;p&gt;Then they get asked to design something slightly different, and nothing transfers.&lt;/p&gt;

&lt;p&gt;The fix is to learn &lt;em&gt;reasoning&lt;/em&gt;, not answers. For every component you study, learn two things: &lt;strong&gt;what problem it solves&lt;/strong&gt; and &lt;strong&gt;what new problem it creates.&lt;/strong&gt; A cache makes reads fast (solves latency) but can serve stale data (creates a consistency problem). A queue smooths traffic spikes (solves load) but adds delay and complexity (creates new failure modes). Once you think in those trade-offs, you can design things you have never seen before. That is the whole game.&lt;/p&gt;

&lt;h2&gt;
  
  
  Your first design: build it, don't read it
&lt;/h2&gt;

&lt;p&gt;Reading designs builds recognition. Building one builds competence. So for your very first system, pick something small enough to finish in one sitting and deep enough to teach the core ideas. The classic choice is a URL shortener (think bit.ly), and it is the perfect no-experience starter.&lt;/p&gt;

&lt;p&gt;Here is the trick that makes it work: &lt;strong&gt;start with the dumbest possible version, then break it on purpose.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Version 1, the naive design.&lt;/strong&gt; One server, one database. A user submits a long URL, you generate a short code, store the pair, and redirect on lookup. That's it. It works for ten users. Congratulations, you have designed a system.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Now add a constraint.&lt;/strong&gt; "It needs to handle 100 million redirects a day." Suddenly your single database read on every redirect is a problem. What solves slow reads? A cache. So you add one. (And now you own the staleness trade-off you just learned about.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add another.&lt;/strong&gt; "Short codes must never collide." Now you have to think about how codes are generated: random with a uniqueness check, or a counter, or a hash. Each has trade-offs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add one more.&lt;/strong&gt; "One database server can't hold all the data." Now you need to split it across machines, which is your gentle introduction to sharding.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See what happened? Each constraint forced &lt;em&gt;exactly one&lt;/em&gt; new idea, and you learned that idea because you needed it, not because a textbook listed it. That is how real systems grow, and it is how you should learn. For a full worked version of this exact problem, see my walkthrough of &lt;a href="https://dev.to/arslan_ah/system-design-interview-question-designing-a-url-shortening-service-4029"&gt;designing a URL shortening service&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to build intuition without a production system
&lt;/h2&gt;

&lt;p&gt;You can't experiment on real traffic yet, so build intuition these three ways instead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Read with a question, not a highlighter.&lt;/strong&gt; When you read how a real system works, stop at each component and ask "what would break if they removed this?" If you can answer, you understand it. If you can't, that's the part to study next.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build small versions for real.&lt;/strong&gt; A rate limiter is a weekend project. A simple key-value cache is a weekend project. A basic message queue is a weekend project. Building a tiny version teaches you more than reading about the big version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reason about apps you already use.&lt;/strong&gt; Every time you use an app, ask one design question. Why does the like count sometimes look slightly off? (Probably caching.) Why can you send a message offline and it sends later? (Probably a queue.) You are surrounded by free case studies.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A 4-week beginner ramp
&lt;/h2&gt;

&lt;p&gt;If you want a path instead of a pile of topics, here is a realistic one. Forty focused minutes a day beats a frantic weekend.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 1: Foundations.&lt;/strong&gt; One building block per day: load balancer, cache, database replication, sharding, message queue. For each, write three sentences (what it solves, what it costs, when to use it).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 2: Your first systems.&lt;/strong&gt; Design the URL shortener end to end, evolving it under constraints as shown above. Then do a second small one (a pastebin or a basic image host) the same way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 3: A bigger system.&lt;/strong&gt; Attempt a news feed or a chat app. You will get stuck. That is the point; the stuck moments tell you exactly what to study next.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Week 4: Practice out loud.&lt;/strong&gt; Re-design two earlier systems from a blank page, talking through every decision as if explaining to someone. If you can't explain a choice, you haven't learned it yet.&lt;/p&gt;

&lt;p&gt;After four weeks you won't be a senior architect, but you will no longer be a beginner, and you will know how to keep going.&lt;/p&gt;

&lt;h2&gt;
  
  
  Beginner mistakes to skip
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Starting with the "impressive" architecture.&lt;/strong&gt; Microservices and Kafka on day one is a red flag, not a flex. Start simple, justify every addition.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memorizing reference designs.&lt;/strong&gt; You will be asked something off-script. Learn the reasoning.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Studying components you never use.&lt;/strong&gt; You don't need to deeply understand distributed consensus to design a URL shortener. Learn things when a problem demands them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practicing silently.&lt;/strong&gt; System design is a communication skill. If you only think it through in your head, you are training the wrong muscle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Skipping the math.&lt;/strong&gt; "It scales" is not an answer. Rough numbers are what justify your choices.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Do I really not need experience with big systems?&lt;/strong&gt;&lt;br&gt;
Correct. Experience accelerates intuition later, but the building-block-then-composition path works fine without it. Many engineers learn system design before ever operating one at scale.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How long until I'm "good"?&lt;/strong&gt;&lt;br&gt;
For a solid beginner foundation, about 4 weeks of consistent practice. Genuine mastery is a multi-year, on-the-job journey, and that's normal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is this only useful for interviews?&lt;/strong&gt;&lt;br&gt;
No. The same skill (making and defending trade-offs) is exactly what you do when designing real systems at work. Interview prep is just a concentrated version of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to go next
&lt;/h2&gt;

&lt;p&gt;Once the fundamentals click, the natural next step is to study what depth is expected at each stage of your career. When you're ready, here's &lt;a href="https://www.designgurus.io/learn-system-design" rel="noopener noreferrer"&gt;where to start learning system design&lt;/a&gt; with a level-by-level path, and a companion roadmap that lays out the same journey &lt;a href="https://dev.to/arslan_ah/how-to-learn-system-design-a-roadmap-by-career-level-3e01"&gt;as a roadmap by career level&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The engineers who get good at this are not the ones who read the most. They are the ones who designed the most systems out loud, starting with the dumbest possible version and letting the constraints teach them. You can start that today, with zero experience. Pick the URL shortener, build the naive version, then break it.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>beginners</category>
      <category>career</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to Learn System Design: A Roadmap by Career Level</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Mon, 29 Jun 2026 10:53:47 +0000</pubDate>
      <link>https://dev.to/arslan_ah/how-to-learn-system-design-a-roadmap-by-career-level-3e01</link>
      <guid>https://dev.to/arslan_ah/how-to-learn-system-design-a-roadmap-by-career-level-3e01</guid>
      <description>&lt;p&gt;Most engineers do not struggle with system design because they lack intelligence. They struggle because the topic has no obvious starting point and no obvious finish line. Coding has LeetCode. System design has... a thousand blog posts, a few thick books, and a lot of hand-waving about "scalability."&lt;/p&gt;

&lt;p&gt;This guide fixes the starting-point problem. It lays out how to learn system design as a sequence: what to learn first, what to learn next, and what "good enough" looks like at each stage of your career. If you want the fuller, continuously updated version, Design Gurus maintains a structured guide on &lt;a href="https://www.designgurus.io/learn-system-design" rel="noopener noreferrer"&gt;how to learn system design&lt;/a&gt; organized by career level. This article gives you the condensed roadmap.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learning system design is not memorizing architectures
&lt;/h2&gt;

&lt;p&gt;The most common mistake is treating system design like trivia: memorize how Twitter's feed works, how Uber matches drivers, how a URL shortener generates keys. You can recite all of it and still freeze when asked to design something you have not seen.&lt;/p&gt;

&lt;p&gt;System design is a &lt;em&gt;skill&lt;/em&gt;, not a &lt;em&gt;fact set&lt;/em&gt;. The skill is this: given a vague problem and real constraints, make a sequence of defensible trade-offs and communicate them clearly. Everything below is built to train that skill, not to pad your memory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites: what you need before you start
&lt;/h2&gt;

&lt;p&gt;You do not need to be a senior engineer to begin, but you do need a few fundamentals. If any of these are shaky, shore them up first:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Networking basics:&lt;/strong&gt; what happens when a client calls a server (DNS, TCP, HTTP, status codes).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Databases:&lt;/strong&gt; the difference between a relational and a non-relational store, what an index is, what a transaction is.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Concurrency basics:&lt;/strong&gt; what a race condition is, why shared state is hard.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Back-of-the-envelope math:&lt;/strong&gt; powers of two, latency numbers, how to estimate QPS and storage.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you can comfortably explain those at a whiteboard, you are ready.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three-phase learning path
&lt;/h2&gt;

&lt;p&gt;Every effective learning sequence I have seen follows the same arc. Skipping a phase is the fastest way to plateau.&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 1: Foundations (learn the building blocks in isolation)
&lt;/h3&gt;

&lt;p&gt;Before you compose a system, you need to understand its parts well enough to know when each one applies. Learn these one at a time, and for each, learn &lt;em&gt;what problem it solves&lt;/em&gt; and &lt;em&gt;what it costs&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Load balancers&lt;/li&gt;
&lt;li&gt;Caching (and cache invalidation strategies)&lt;/li&gt;
&lt;li&gt;Database replication and sharding&lt;/li&gt;
&lt;li&gt;Message queues and asynchronous processing&lt;/li&gt;
&lt;li&gt;Consistent hashing&lt;/li&gt;
&lt;li&gt;CDNs&lt;/li&gt;
&lt;li&gt;Rate limiting&lt;/li&gt;
&lt;li&gt;Indexing and data modeling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Do not move on until you can answer, for each: "When would I add this, and what new problem does adding it create?" Caching, for example, solves latency but creates staleness. That trade-off framing is the entire game.&lt;/p&gt;

&lt;p&gt;For a deeper breakdown of each block (what it solves, what it costs, and when to reach for it), see &lt;a href="https://dev.to/arslan_ah/system-design-fundamentals-the-10-building-blocks-to-learn-first-2754"&gt;the 10 system design building blocks to learn first&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 2: Composition (assemble blocks into systems)
&lt;/h3&gt;

&lt;p&gt;Now combine the blocks. Take a classic prompt and build it up incrementally. A good first target is a URL shortener: simple enough to finish, deep enough to touch key generation, storage, caching, and read/write skew.&lt;/p&gt;

&lt;p&gt;The key habit here is to &lt;strong&gt;start simple and evolve under pressure&lt;/strong&gt;. Begin with the naive single-server design, then introduce a constraint ("now it serves 100M requests a day") and react to it. Each constraint should force exactly one architectural change. That is how real systems grow, and it is how interviewers expect you to think.&lt;/p&gt;

&lt;p&gt;Work through 8 to 12 canonical systems this way: a news feed, a chat app, a rate limiter, a typeahead service, a video platform, a ride-sharing matcher, a notification system. The repetition builds pattern recognition.&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 3: Practice (perform under realistic conditions)
&lt;/h3&gt;

&lt;p&gt;Reading designs builds recognition. Producing them under a clock builds competence. In this phase you design out loud, on a timer, ideally with someone pushing back. The full &lt;a href="https://www.designgurus.io/learn-system-design" rel="noopener noreferrer"&gt;system design learning roadmap by level&lt;/a&gt; breaks down how much practice each career stage actually needs, but the principle is constant: you only own a concept once you can explain it without notes.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to learn at each career level
&lt;/h2&gt;

&lt;p&gt;"Learn system design" means different things depending on where you are. Calibrate your depth to your target level so you neither under-prepare nor waste months on staff-level concerns you will not be asked about.&lt;/p&gt;

&lt;h3&gt;
  
  
  Junior (L3)
&lt;/h3&gt;

&lt;p&gt;The bar is fundamentals, not novel architecture. You should be able to design a basic CRUD service, expose a clean API, pick a reasonable database, and explain a single caching layer. Depth of building blocks matters more than breadth of systems.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mid-level (L4)
&lt;/h3&gt;

&lt;p&gt;Now you compose. You should design a complete system end to end, identify bottlenecks, and reason about scaling reads vs writes. You are expected to know when to shard, when to add a queue, and what consistency model fits the use case.&lt;/p&gt;

&lt;h3&gt;
  
  
  Senior (L5)
&lt;/h3&gt;

&lt;p&gt;The focus shifts to trade-offs and justification. Two valid designs exist for almost every problem; your job is to pick one and defend it against the alternative. Expect deep dives: "Walk me through exactly how you keep the cache consistent here." Non-functional requirements (availability, latency targets, cost) drive your decisions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Staff and above (L6+)
&lt;/h3&gt;

&lt;p&gt;The scope widens beyond one system to platforms and organizations. You reason about evolvability, migration paths, failure domains, multi-region strategy, and the human cost of operating what you propose. The question is less "does it work" and more "will this still be the right call in three years."&lt;/p&gt;

&lt;h2&gt;
  
  
  A concrete weekly cadence
&lt;/h2&gt;

&lt;p&gt;If you want a plan rather than a pile of topics, here is a sustainable rhythm:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Weeks 1 to 2:&lt;/strong&gt; One building block per day from Phase 1. Write a three-sentence summary of each (problem it solves, cost it adds, when to reach for it).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Weeks 3 to 5:&lt;/strong&gt; One full system every two days from Phase 2, evolving each from naive to scaled.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Weeks 6 onward:&lt;/strong&gt; Timed mock designs from Phase 3, two per week, reviewed honestly afterward.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Consistency beats intensity. Forty focused minutes a day will outperform a frantic weekend cram every time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes that stall people
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Jumping to the "impressive" architecture immediately.&lt;/strong&gt; Start with the simplest thing that works, then justify each addition. Leading with Kafka and microservices for a problem that needs neither is a red flag.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memorizing reference designs.&lt;/strong&gt; You will be asked something off-script. Learn the reasoning, not the diagram.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ignoring requirements.&lt;/strong&gt; Spending zero time clarifying scope and then designing the wrong system is the most common failure mode, and the most avoidable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practicing silently.&lt;/strong&gt; System design is a communication exercise. If you only practice in your head, you are training the wrong muscle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Skipping the math.&lt;/strong&gt; "It scales" is not an answer. Numbers (QPS, storage, bandwidth) are what justify your choices.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;How long does it take to learn system design?&lt;/strong&gt;&lt;br&gt;
For interview readiness, most engineers need 4 to 8 weeks of consistent practice on top of solid fundamentals. Genuine mastery is a multi-year, on-the-job process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do I need real distributed-systems experience first?&lt;/strong&gt;&lt;br&gt;
No. Experience helps, but the building-block-then-composition path works without it. Plenty of engineers learn this before they have ever operated a large system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is system design only for interviews?&lt;/strong&gt;&lt;br&gt;
No. The same skill (making and defending architectural trade-offs) is exactly what you do when designing real systems at work. Interview prep is just a focused version of it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do I need real distributed-systems experience first?&lt;/strong&gt;&lt;br&gt;
No. Experience helps, but the building-block-then-composition path works without it. Plenty of engineers learn this before they have ever operated a large system. If you're starting from zero, I wrote a companion guide on &lt;a href="https://dev.to/arslan_ah/how-to-learn-system-design-from-scratch-with-no-distributed-systems-experience-1591"&gt;learning system design from scratch with no experience&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to go next
&lt;/h2&gt;

&lt;p&gt;Pick your level, start at Phase 1, and do not skip ahead. If you want the structured, regularly updated version of this path with level-specific checklists, work through Design Gurus' guide on &lt;a href="https://www.designgurus.io/learn-system-design" rel="noopener noreferrer"&gt;how to learn system design&lt;/a&gt;. And when you are ready to drill full problems with worked solutions, &lt;a href="https://www.designgurus.io/course/grokking-the-system-design-interview" rel="noopener noreferrer"&gt;Grokking the System Design Interview&lt;/a&gt; walks through the canonical systems end to end.&lt;/p&gt;

&lt;p&gt;The engineers who get good at this are not the ones who read the most. They are the ones who designed the most systems out loud. Start today, start simple, and let the constraints teach you.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>programming</category>
      <category>interview</category>
      <category>career</category>
    </item>
    <item>
      <title>Must-do system design questions.</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Thu, 25 Jun 2026 11:39:21 +0000</pubDate>
      <link>https://dev.to/arslan_ah/must-do-system-design-questions-4n46</link>
      <guid>https://dev.to/arslan_ah/must-do-system-design-questions-4n46</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m" class="crayons-story__hidden-navigation-link"&gt;64 System Design Interview Questions, Ranked From Easiest to Hardest&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/arslan_ah" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F34147%2F2974e0a5-f688-45b5-a4c9-5fa49c257854.jpg" alt="arslan_ah profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/arslan_ah" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Arslan Ahmad
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Arslan Ahmad
                
              
              &lt;div id="story-author-preview-content-3488973" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/arslan_ah" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F34147%2F2974e0a5-f688-45b5-a4c9-5fa49c257854.jpg" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Arslan Ahmad&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Apr 12&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m" id="article-link-3488973"&gt;
          64 System Design Interview Questions, Ranked From Easiest to Hardest
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/systemdesign"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;systemdesign&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/softwaredevelopment"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;softwaredevelopment&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/interview"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;interview&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/ai"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;ai&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;16&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            19 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
      <category>architecture</category>
      <category>career</category>
      <category>interview</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>AI System Design Interview Questions: ChatGPT, RAG, LLM Inference, and Agents</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Thu, 25 Jun 2026 11:38:22 +0000</pubDate>
      <link>https://dev.to/arslan_ah/ai-system-design-interview-questions-chatgpt-rag-llm-inference-and-agents-1doi</link>
      <guid>https://dev.to/arslan_ah/ai-system-design-interview-questions-chatgpt-rag-llm-inference-and-agents-1doi</guid>
      <description>&lt;p&gt;System design interviews are changing.&lt;/p&gt;

&lt;p&gt;Traditional questions such as “Design Twitter,” “Design Uber,” and “Design YouTube” are still important. They test whether you understand databases, caching, partitioning, replication, messaging, and high availability.&lt;/p&gt;

&lt;p&gt;But engineers working on modern platforms now encounter a different category of problem:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Design a ChatGPT-like conversational assistant.&lt;/li&gt;
&lt;li&gt;Design a retrieval-augmented generation system.&lt;/li&gt;
&lt;li&gt;Design an LLM inference platform.&lt;/li&gt;
&lt;li&gt;Design an AI agent that can call external tools.&lt;/li&gt;
&lt;li&gt;Design an enterprise AI assistant for private documents.&lt;/li&gt;
&lt;li&gt;Design an evaluation platform for generative AI applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These questions still require classical distributed-systems knowledge. An AI product needs APIs, queues, storage, authentication, observability, rate limiting, and reliable deployment.&lt;/p&gt;

&lt;p&gt;The difference is that it also introduces expensive accelerators, probabilistic output, long-running requests, model routing, vector retrieval, prompt construction, safety controls, and quality evaluation.&lt;/p&gt;

&lt;p&gt;This guide explains the most important AI system design interview questions and what a strong candidate should discuss for each.&lt;/p&gt;

&lt;p&gt;For a broader preparation roadmap covering traditional and modern problems, see &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m"&gt;64 System Design Interview Questions, Ranked From Easiest to Hardest&lt;/a&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why AI System Design Is Different
&lt;/h1&gt;

&lt;p&gt;A conventional service usually transforms an input into a deterministic output.&lt;/p&gt;

&lt;p&gt;If a user requests order number 123, the service should retrieve order 123. Two identical requests should usually return the same underlying information.&lt;/p&gt;

&lt;p&gt;Generative AI systems behave differently.&lt;/p&gt;

&lt;p&gt;A model may produce different responses to the same prompt. A response can be grammatically convincing while being factually wrong. Latency depends on the number of generated tokens. Serving capacity is constrained by accelerator memory, not merely CPU utilization. Product quality may depend on prompts, retrieved context, model versions, safety filters, and external tools.&lt;/p&gt;

&lt;p&gt;This creates several new design dimensions.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Quality is part of the architecture
&lt;/h2&gt;

&lt;p&gt;Traditional systems are often measured using availability, latency, throughput, and error rate.&lt;/p&gt;

&lt;p&gt;AI systems need those metrics, but they also need measures such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Answer correctness&lt;/li&gt;
&lt;li&gt;Relevance&lt;/li&gt;
&lt;li&gt;Groundedness&lt;/li&gt;
&lt;li&gt;Retrieval quality&lt;/li&gt;
&lt;li&gt;Hallucination rate&lt;/li&gt;
&lt;li&gt;Tool-use success&lt;/li&gt;
&lt;li&gt;Safety-policy compliance&lt;/li&gt;
&lt;li&gt;User satisfaction&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A system that returns a response in 200 milliseconds is not useful if that response is wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Requests are computationally expensive
&lt;/h2&gt;

&lt;p&gt;An ordinary API server may process thousands of lightweight requests per second.&lt;/p&gt;

&lt;p&gt;An LLM request can occupy expensive GPU memory while processing a long prompt and generating hundreds of tokens. The architecture must therefore optimize batching, memory utilization, model placement, and request scheduling.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Latency is experienced as a stream
&lt;/h2&gt;

&lt;p&gt;Users do not normally wait for an entire answer before seeing anything. Tokens are streamed as they are generated.&lt;/p&gt;

&lt;p&gt;This introduces at least two important latency measurements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Time to first token:&lt;/strong&gt; How quickly generation begins.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inter-token latency:&lt;/strong&gt; How smoothly subsequent tokens arrive.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A system may have acceptable total latency but still feel slow if the first token takes too long.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Data enters the system in several ways
&lt;/h2&gt;

&lt;p&gt;An AI application may depend on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Model-training data&lt;/li&gt;
&lt;li&gt;User prompts&lt;/li&gt;
&lt;li&gt;Conversation history&lt;/li&gt;
&lt;li&gt;Retrieved documents&lt;/li&gt;
&lt;li&gt;Tool results&lt;/li&gt;
&lt;li&gt;Feedback&lt;/li&gt;
&lt;li&gt;Evaluation datasets&lt;/li&gt;
&lt;li&gt;Safety policies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each data type has distinct requirements for retention, privacy, freshness, and consistency.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Failure is not always binary
&lt;/h2&gt;

&lt;p&gt;A traditional request may succeed or fail.&lt;/p&gt;

&lt;p&gt;An AI request can technically succeed but produce a low-quality answer, retrieve the wrong documents, call the wrong tool, exceed a cost budget, or violate a safety rule.&lt;/p&gt;

&lt;p&gt;The architecture must detect and respond to these softer failure modes.&lt;/p&gt;




&lt;h1&gt;
  
  
  A Framework for Answering Any AI System Design Question
&lt;/h1&gt;

&lt;p&gt;Before considering individual questions, use a consistent interview structure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Clarify the product
&lt;/h2&gt;

&lt;p&gt;Ask what the system is expected to do.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is the assistant general-purpose or domain-specific?&lt;/li&gt;
&lt;li&gt;Does it need private enterprise data?&lt;/li&gt;
&lt;li&gt;Can it take actions or only provide answers?&lt;/li&gt;
&lt;li&gt;Does it support text only, or also images, audio, and files?&lt;/li&gt;
&lt;li&gt;Are responses expected in real time?&lt;/li&gt;
&lt;li&gt;Does the system need citations?&lt;/li&gt;
&lt;li&gt;Which decisions require human approval?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without this clarification, “Design an AI assistant” is too broad.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Define scale and service-level objectives
&lt;/h2&gt;

&lt;p&gt;Estimate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Daily and peak requests&lt;/li&gt;
&lt;li&gt;Average prompt size&lt;/li&gt;
&lt;li&gt;Average output length&lt;/li&gt;
&lt;li&gt;Concurrent users&lt;/li&gt;
&lt;li&gt;Required time to first token&lt;/li&gt;
&lt;li&gt;Model size&lt;/li&gt;
&lt;li&gt;GPU-memory requirements&lt;/li&gt;
&lt;li&gt;Availability target&lt;/li&gt;
&lt;li&gt;Cost per request&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;AI systems are often constrained by cost as much as by technical capacity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Separate the application layer from the model layer
&lt;/h2&gt;

&lt;p&gt;The application layer may include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Authentication&lt;/li&gt;
&lt;li&gt;Billing&lt;/li&gt;
&lt;li&gt;Conversation history&lt;/li&gt;
&lt;li&gt;File management&lt;/li&gt;
&lt;li&gt;User preferences&lt;/li&gt;
&lt;li&gt;Rate limiting&lt;/li&gt;
&lt;li&gt;Analytics&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The AI layer may include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prompt construction&lt;/li&gt;
&lt;li&gt;Retrieval&lt;/li&gt;
&lt;li&gt;Model routing&lt;/li&gt;
&lt;li&gt;Inference scheduling&lt;/li&gt;
&lt;li&gt;Safety checks&lt;/li&gt;
&lt;li&gt;Tool execution&lt;/li&gt;
&lt;li&gt;Evaluation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keeping these concerns separate makes the design easier to explain and evolve.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Trace the complete request path
&lt;/h2&gt;

&lt;p&gt;Describe what happens from the moment a user submits a prompt until the final result is displayed.&lt;/p&gt;

&lt;p&gt;A typical path may be:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Authenticate the request.&lt;/li&gt;
&lt;li&gt;Enforce quotas.&lt;/li&gt;
&lt;li&gt;Load conversation state.&lt;/li&gt;
&lt;li&gt;Retrieve relevant context.&lt;/li&gt;
&lt;li&gt;Construct the model prompt.&lt;/li&gt;
&lt;li&gt;Run input-safety checks.&lt;/li&gt;
&lt;li&gt;Select a model.&lt;/li&gt;
&lt;li&gt;Schedule inference.&lt;/li&gt;
&lt;li&gt;Stream tokens.&lt;/li&gt;
&lt;li&gt;Run output-safety checks.&lt;/li&gt;
&lt;li&gt;Store the response.&lt;/li&gt;
&lt;li&gt;Record metrics and feedback.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 5: Discuss failure, quality, and cost
&lt;/h2&gt;

&lt;p&gt;A strong answer should explain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What happens when the primary model is overloaded?&lt;/li&gt;
&lt;li&gt;What happens when retrieval returns no useful documents?&lt;/li&gt;
&lt;li&gt;How are duplicate tool calls prevented?&lt;/li&gt;
&lt;li&gt;How does the system degrade gracefully?&lt;/li&gt;
&lt;li&gt;How are model changes evaluated?&lt;/li&gt;
&lt;li&gt;How is tenant data isolated?&lt;/li&gt;
&lt;li&gt;How are expensive requests controlled?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These discussions distinguish a production design from a demo.&lt;/p&gt;




&lt;h1&gt;
  
  
  Question 1: Design ChatGPT
&lt;/h1&gt;

&lt;p&gt;A ChatGPT-like system is one of the most comprehensive AI system design questions.&lt;/p&gt;

&lt;p&gt;The functional requirements may include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Starting a conversation&lt;/li&gt;
&lt;li&gt;Sending prompts&lt;/li&gt;
&lt;li&gt;Receiving streamed responses&lt;/li&gt;
&lt;li&gt;Viewing conversation history&lt;/li&gt;
&lt;li&gt;Regenerating an answer&lt;/li&gt;
&lt;li&gt;Uploading files&lt;/li&gt;
&lt;li&gt;Choosing among models&lt;/li&gt;
&lt;li&gt;Enforcing free and paid usage limits&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A useful high-level architecture contains the following components.&lt;/p&gt;

&lt;h2&gt;
  
  
  API gateway
&lt;/h2&gt;

&lt;p&gt;The gateway handles authentication, request routing, rate limiting, quotas, and basic validation.&lt;/p&gt;

&lt;p&gt;Long-running generation requests may use Server-Sent Events or WebSockets to stream tokens to clients.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conversation service
&lt;/h2&gt;

&lt;p&gt;This service manages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Conversations&lt;/li&gt;
&lt;li&gt;Messages&lt;/li&gt;
&lt;li&gt;User preferences&lt;/li&gt;
&lt;li&gt;Message ordering&lt;/li&gt;
&lt;li&gt;Conversation titles&lt;/li&gt;
&lt;li&gt;Retention and deletion&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Conversation metadata can live in a transactional database, while large attachments may be placed in object storage.&lt;/p&gt;

&lt;h2&gt;
  
  
  Context builder
&lt;/h2&gt;

&lt;p&gt;Models have finite context windows. The context builder decides what information should be included in the next request.&lt;/p&gt;

&lt;p&gt;It may combine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The system prompt&lt;/li&gt;
&lt;li&gt;Recent conversation messages&lt;/li&gt;
&lt;li&gt;A summary of older messages&lt;/li&gt;
&lt;li&gt;Retrieved documents&lt;/li&gt;
&lt;li&gt;User preferences&lt;/li&gt;
&lt;li&gt;Tool outputs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Simply sending the entire conversation forever is expensive and eventually impossible. Older content may need summarization or selective retrieval.&lt;/p&gt;

&lt;h2&gt;
  
  
  Model gateway
&lt;/h2&gt;

&lt;p&gt;The model gateway provides a single interface to multiple model backends.&lt;/p&gt;

&lt;p&gt;It can route requests based on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Task type&lt;/li&gt;
&lt;li&gt;Required quality&lt;/li&gt;
&lt;li&gt;User subscription&lt;/li&gt;
&lt;li&gt;Context length&lt;/li&gt;
&lt;li&gt;Latency target&lt;/li&gt;
&lt;li&gt;Current capacity&lt;/li&gt;
&lt;li&gt;Cost budget&lt;/li&gt;
&lt;li&gt;Model availability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A simple request may use a smaller, faster model, while complex reasoning may be routed to a more capable one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inference scheduler
&lt;/h2&gt;

&lt;p&gt;The scheduler assigns requests to model replicas running on accelerators.&lt;/p&gt;

&lt;p&gt;It should consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Available GPU memory&lt;/li&gt;
&lt;li&gt;Model placement&lt;/li&gt;
&lt;li&gt;Prompt length&lt;/li&gt;
&lt;li&gt;Output-token budget&lt;/li&gt;
&lt;li&gt;Priority&lt;/li&gt;
&lt;li&gt;Batch compatibility&lt;/li&gt;
&lt;li&gt;Tenant quotas&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A naive first-in, first-out scheduler can allow a few extremely long prompts to delay many short requests.&lt;/p&gt;

&lt;h2&gt;
  
  
  Streaming layer
&lt;/h2&gt;

&lt;p&gt;Generated tokens should be forwarded incrementally to the user.&lt;/p&gt;

&lt;p&gt;The system must also handle:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Client disconnections&lt;/li&gt;
&lt;li&gt;User cancellation&lt;/li&gt;
&lt;li&gt;Partial responses&lt;/li&gt;
&lt;li&gt;Network retries&lt;/li&gt;
&lt;li&gt;Moderation during generation&lt;/li&gt;
&lt;li&gt;Final persistence after streaming completes&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Safety layer
&lt;/h2&gt;

&lt;p&gt;Input and output policies may detect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prompt injection&lt;/li&gt;
&lt;li&gt;Sensitive information&lt;/li&gt;
&lt;li&gt;Disallowed requests&lt;/li&gt;
&lt;li&gt;Malicious files&lt;/li&gt;
&lt;li&gt;Unsafe tool instructions&lt;/li&gt;
&lt;li&gt;Data leakage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Safety should not be treated as one filter placed at the end. Different checks may be required before retrieval, before tool execution, before inference, and before returning the final response.&lt;/p&gt;

&lt;h2&gt;
  
  
  Important deep dives
&lt;/h2&gt;

&lt;p&gt;An interviewer may ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How would you reduce time to first token?&lt;/li&gt;
&lt;li&gt;How would you support 100 million users?&lt;/li&gt;
&lt;li&gt;How would you prevent one tenant from consuming all GPU capacity?&lt;/li&gt;
&lt;li&gt;How would you summarize long conversations?&lt;/li&gt;
&lt;li&gt;How would you route between multiple models?&lt;/li&gt;
&lt;li&gt;How would you preserve availability during GPU shortages?&lt;/li&gt;
&lt;li&gt;How would you limit the cost for free users?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;a href="https://www.designgurus.io/course-play/system-design-interview-crash-course/doc/design-chatgpt" rel="noopener noreferrer"&gt;Design ChatGPT walkthrough&lt;/a&gt; provides a structured example of this problem.&lt;/p&gt;




&lt;h1&gt;
  
  
  Question 2: Design a RAG System
&lt;/h1&gt;

&lt;p&gt;Retrieval-augmented generation, or RAG, allows a model to answer using information retrieved from external sources.&lt;/p&gt;

&lt;p&gt;A common interview prompt is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Design an enterprise assistant that answers employee questions using internal documents and provides citations.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A RAG system has two major paths:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The ingestion path&lt;/li&gt;
&lt;li&gt;The query path&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The ingestion path
&lt;/h2&gt;

&lt;p&gt;Documents may come from file uploads, internal wikis, cloud drives, databases, or support systems.&lt;/p&gt;

&lt;p&gt;The ingestion pipeline performs several stages.&lt;/p&gt;

&lt;h3&gt;
  
  
  Document extraction
&lt;/h3&gt;

&lt;p&gt;Files must be converted into usable text.&lt;/p&gt;

&lt;p&gt;The system may need parsers for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PDFs&lt;/li&gt;
&lt;li&gt;Word documents&lt;/li&gt;
&lt;li&gt;Presentations&lt;/li&gt;
&lt;li&gt;HTML pages&lt;/li&gt;
&lt;li&gt;Spreadsheets&lt;/li&gt;
&lt;li&gt;Scanned images&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The extraction process should preserve useful metadata such as titles, headings, page numbers, owners, and access permissions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Chunking
&lt;/h3&gt;

&lt;p&gt;Long documents are divided into smaller segments.&lt;/p&gt;

&lt;p&gt;Chunks that are too large may contain irrelevant text and consume excessive context. Chunks that are too small may lose meaning.&lt;/p&gt;

&lt;p&gt;Possible strategies include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fixed token windows&lt;/li&gt;
&lt;li&gt;Paragraph-based chunking&lt;/li&gt;
&lt;li&gt;Heading-aware chunking&lt;/li&gt;
&lt;li&gt;Overlapping windows&lt;/li&gt;
&lt;li&gt;Semantic chunking&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is no universally correct chunk size. It should be tested against representative questions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Embedding generation
&lt;/h3&gt;

&lt;p&gt;Each chunk is converted into a numerical vector using an embedding model.&lt;/p&gt;

&lt;p&gt;The embedding service should be versioned because changing models can require re-embedding the entire corpus.&lt;/p&gt;

&lt;h3&gt;
  
  
  Indexing
&lt;/h3&gt;

&lt;p&gt;The system stores:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Embeddings&lt;/li&gt;
&lt;li&gt;Original text&lt;/li&gt;
&lt;li&gt;Document metadata&lt;/li&gt;
&lt;li&gt;Access-control information&lt;/li&gt;
&lt;li&gt;Source location&lt;/li&gt;
&lt;li&gt;Embedding version&lt;/li&gt;
&lt;li&gt;Update timestamp&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A vector index enables semantic retrieval. A traditional inverted index can support keyword retrieval. Many production systems combine both.&lt;/p&gt;

&lt;h2&gt;
  
  
  The query path
&lt;/h2&gt;

&lt;p&gt;When a user submits a question:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Authenticate the user.&lt;/li&gt;
&lt;li&gt;Generate an embedding for the query.&lt;/li&gt;
&lt;li&gt;Retrieve candidate chunks.&lt;/li&gt;
&lt;li&gt;Apply access-control filtering.&lt;/li&gt;
&lt;li&gt;Rerank the candidates.&lt;/li&gt;
&lt;li&gt;Select the best context.&lt;/li&gt;
&lt;li&gt;Construct the prompt.&lt;/li&gt;
&lt;li&gt;Generate the answer.&lt;/li&gt;
&lt;li&gt;Attach citations.&lt;/li&gt;
&lt;li&gt;Evaluate or log the result.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Hybrid retrieval
&lt;/h2&gt;

&lt;p&gt;Semantic retrieval is useful when the query and source use different words with similar meanings.&lt;/p&gt;

&lt;p&gt;Keyword retrieval is useful for exact terms such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Product codes&lt;/li&gt;
&lt;li&gt;Error messages&lt;/li&gt;
&lt;li&gt;Names&lt;/li&gt;
&lt;li&gt;Dates&lt;/li&gt;
&lt;li&gt;Identifiers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Combining both methods often produces better coverage.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reranking
&lt;/h2&gt;

&lt;p&gt;Vector similarity may retrieve documents that are generally related but not directly useful.&lt;/p&gt;

&lt;p&gt;A reranker can score the top candidates more accurately before they are sent to the LLM. This improves answer quality while keeping the final prompt small.&lt;/p&gt;

&lt;h2&gt;
  
  
  Access control
&lt;/h2&gt;

&lt;p&gt;Security is one of the most important parts of enterprise RAG.&lt;/p&gt;

&lt;p&gt;A user should never retrieve a document they are not authorized to view. Filtering after the model has already received the document is too late.&lt;/p&gt;

&lt;p&gt;Permissions should be enforced during retrieval, with tenant and user identity included in the query path.&lt;/p&gt;

&lt;h2&gt;
  
  
  Freshness and deletion
&lt;/h2&gt;

&lt;p&gt;The system must react when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A document changes.&lt;/li&gt;
&lt;li&gt;A document is deleted.&lt;/li&gt;
&lt;li&gt;Permissions change.&lt;/li&gt;
&lt;li&gt;A user loses access.&lt;/li&gt;
&lt;li&gt;A newer policy replaces an older one.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The ingestion pipeline may use event-driven updates, periodic crawling, or both.&lt;/p&gt;

&lt;h2&gt;
  
  
  RAG evaluation
&lt;/h2&gt;

&lt;p&gt;A RAG system should separately evaluate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Retrieval quality:&lt;/strong&gt; Did the system find the relevant document?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Generation quality:&lt;/strong&gt; Did the model use the retrieved context correctly?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Citation quality:&lt;/strong&gt; Do the cited sources actually support the answer?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This separation is important. A poor answer can result from failed retrieval even when the model behaves correctly.&lt;/p&gt;




&lt;h1&gt;
  
  
  Question 3: Design an LLM Inference Platform
&lt;/h1&gt;

&lt;p&gt;This question focuses less on the product interface and more on the infrastructure that serves models.&lt;/p&gt;

&lt;p&gt;A possible prompt is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Design a multi-tenant platform that serves several large language models to millions of requests.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The platform may need to support:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiple model families&lt;/li&gt;
&lt;li&gt;Different model sizes&lt;/li&gt;
&lt;li&gt;Streaming generation&lt;/li&gt;
&lt;li&gt;Priority tiers&lt;/li&gt;
&lt;li&gt;Autoscaling&lt;/li&gt;
&lt;li&gt;Usage accounting&lt;/li&gt;
&lt;li&gt;Model versioning&lt;/li&gt;
&lt;li&gt;Regional deployment&lt;/li&gt;
&lt;li&gt;Fine-tuned adapters&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Inference gateway
&lt;/h2&gt;

&lt;p&gt;The gateway exposes a consistent API and performs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Authentication&lt;/li&gt;
&lt;li&gt;Quota enforcement&lt;/li&gt;
&lt;li&gt;Request validation&lt;/li&gt;
&lt;li&gt;Model selection&lt;/li&gt;
&lt;li&gt;Token-limit checks&lt;/li&gt;
&lt;li&gt;Admission control&lt;/li&gt;
&lt;li&gt;Cost estimation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Admission control is critical. Accepting unlimited work and allowing it to queue indefinitely creates poor latency and can destabilize the system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Model registry
&lt;/h2&gt;

&lt;p&gt;The registry tracks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Model version&lt;/li&gt;
&lt;li&gt;Artifact location&lt;/li&gt;
&lt;li&gt;Supported hardware&lt;/li&gt;
&lt;li&gt;Memory requirements&lt;/li&gt;
&lt;li&gt;Context length&lt;/li&gt;
&lt;li&gt;Quantization format&lt;/li&gt;
&lt;li&gt;Deployment status&lt;/li&gt;
&lt;li&gt;Safety and evaluation results&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rollouts should use immutable versions so requests and incidents can be traced to the exact model that served them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Model placement
&lt;/h2&gt;

&lt;p&gt;Loading a large model into GPU memory can take substantial time. The scheduler cannot treat models like lightweight stateless application containers.&lt;/p&gt;

&lt;p&gt;It must decide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which models remain loaded&lt;/li&gt;
&lt;li&gt;How many replicas each model receives&lt;/li&gt;
&lt;li&gt;Where fine-tuned adapters are placed&lt;/li&gt;
&lt;li&gt;When models should be unloaded&lt;/li&gt;
&lt;li&gt;How capacity is distributed across regions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Popular models may remain warm, while rarely used models may accept a cold-start delay.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prefill and decode
&lt;/h2&gt;

&lt;p&gt;LLM inference contains two different computational phases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prefill&lt;/strong&gt; processes the input prompt and can often benefit from parallel computation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Decode&lt;/strong&gt; generates tokens sequentially and is usually memory-bandwidth intensive.&lt;/p&gt;

&lt;p&gt;Separating or independently scheduling these phases can improve utilization, but it also adds network and orchestration complexity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Continuous batching
&lt;/h2&gt;

&lt;p&gt;Instead of waiting for a fixed group of requests to finish together, continuous batching adds and removes requests dynamically as generation progresses.&lt;/p&gt;

&lt;p&gt;This improves GPU utilization, especially when responses have different lengths.&lt;/p&gt;

&lt;p&gt;The scheduler must still prevent long requests from starving shorter ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  KV cache
&lt;/h2&gt;

&lt;p&gt;The key-value cache stores intermediate attention state so the model does not recompute the entire prompt for every generated token.&lt;/p&gt;

&lt;p&gt;KV-cache management affects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Maximum concurrency&lt;/li&gt;
&lt;li&gt;Memory pressure&lt;/li&gt;
&lt;li&gt;Long-context support&lt;/li&gt;
&lt;li&gt;Prefix reuse&lt;/li&gt;
&lt;li&gt;Request eviction&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A shared prompt prefix—such as a large system prompt—may sometimes be cached and reused across compatible requests.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scaling
&lt;/h2&gt;

&lt;p&gt;GPU utilization alone may not be sufficient for autoscaling.&lt;/p&gt;

&lt;p&gt;Useful signals include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Queue length&lt;/li&gt;
&lt;li&gt;Time to first token&lt;/li&gt;
&lt;li&gt;Tokens generated per second&lt;/li&gt;
&lt;li&gt;KV-cache pressure&lt;/li&gt;
&lt;li&gt;Number of active sequences&lt;/li&gt;
&lt;li&gt;Predicted token demand&lt;/li&gt;
&lt;li&gt;Model-specific backlog&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because accelerator provisioning may be slow, the platform may need reserved capacity and predictive scaling.&lt;/p&gt;

&lt;h2&gt;
  
  
  Graceful degradation
&lt;/h2&gt;

&lt;p&gt;When capacity is limited, the system may:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Route to a smaller model.&lt;/li&gt;
&lt;li&gt;Reduce the maximum output length.&lt;/li&gt;
&lt;li&gt;Reject low-priority requests.&lt;/li&gt;
&lt;li&gt;Disable expensive features.&lt;/li&gt;
&lt;li&gt;Queue batch workloads.&lt;/li&gt;
&lt;li&gt;Move traffic to another region.&lt;/li&gt;
&lt;li&gt;Use a third-party model provider.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A strong interview answer discusses the quality and cost consequences of each fallback.&lt;/p&gt;




&lt;h1&gt;
  
  
  Question 4: Design an AI Agent Platform
&lt;/h1&gt;

&lt;p&gt;An AI agent does more than produce text. It can plan a sequence of actions, call tools, observe results, update its state, and continue until a goal is completed.&lt;/p&gt;

&lt;p&gt;A typical prompt might be:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Design an enterprise agent that can search internal documents, update tickets, send emails, and request human approval for sensitive actions.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Core components
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Agent orchestrator
&lt;/h3&gt;

&lt;p&gt;The orchestrator controls the execution loop:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Receive a goal.&lt;/li&gt;
&lt;li&gt;Construct the current context.&lt;/li&gt;
&lt;li&gt;Ask the model for the next action.&lt;/li&gt;
&lt;li&gt;Validate the proposed action.&lt;/li&gt;
&lt;li&gt;Execute the selected tool.&lt;/li&gt;
&lt;li&gt;Store the result.&lt;/li&gt;
&lt;li&gt;Decide whether to continue.&lt;/li&gt;
&lt;li&gt;Produce the final response.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The orchestrator—not the model—should enforce hard limits such as maximum steps, timeouts, budgets, and approval requirements.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tool registry
&lt;/h3&gt;

&lt;p&gt;The tool registry describes each available capability:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tool name&lt;/li&gt;
&lt;li&gt;Purpose&lt;/li&gt;
&lt;li&gt;Input schema&lt;/li&gt;
&lt;li&gt;Required permissions&lt;/li&gt;
&lt;li&gt;Timeout&lt;/li&gt;
&lt;li&gt;Retry policy&lt;/li&gt;
&lt;li&gt;Risk level&lt;/li&gt;
&lt;li&gt;Whether human approval is required&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tool definitions should be versioned because changing their schemas can break existing agent behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tool execution service
&lt;/h3&gt;

&lt;p&gt;Tool calls should run through controlled executors rather than allowing the model unrestricted access to internal systems.&lt;/p&gt;

&lt;p&gt;The executor handles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Authentication&lt;/li&gt;
&lt;li&gt;Input validation&lt;/li&gt;
&lt;li&gt;Secrets&lt;/li&gt;
&lt;li&gt;Network policy&lt;/li&gt;
&lt;li&gt;Timeouts&lt;/li&gt;
&lt;li&gt;Retries&lt;/li&gt;
&lt;li&gt;Audit logging&lt;/li&gt;
&lt;li&gt;Output normalization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;High-risk operations should use narrow, purpose-built APIs.&lt;/p&gt;

&lt;h3&gt;
  
  
  State and memory
&lt;/h3&gt;

&lt;p&gt;Agents may need several kinds of memory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Working memory&lt;/strong&gt; contains the current task, observations, and intermediate steps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Session memory&lt;/strong&gt; preserves information during one user interaction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Long-term memory&lt;/strong&gt; stores information across sessions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;External memory&lt;/strong&gt; may contain documents retrieved from databases or vector indexes.&lt;/p&gt;

&lt;p&gt;Not everything should be stored forever. Memory needs explicit retention, privacy, and deletion policies.&lt;/p&gt;

&lt;h3&gt;
  
  
  Human approval
&lt;/h3&gt;

&lt;p&gt;Actions such as sending payments, deleting data, publishing content, or modifying production systems should not be executed solely because a model requested them.&lt;/p&gt;

&lt;p&gt;The agent can create a proposed action, pause its workflow, and wait for authorized approval.&lt;/p&gt;

&lt;p&gt;The approval record should contain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The intended action&lt;/li&gt;
&lt;li&gt;The relevant parameters&lt;/li&gt;
&lt;li&gt;Why it was proposed&lt;/li&gt;
&lt;li&gt;The expected effect&lt;/li&gt;
&lt;li&gt;The identity of the approver&lt;/li&gt;
&lt;li&gt;An expiration time&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Idempotency
&lt;/h3&gt;

&lt;p&gt;Agents may retry actions after timeouts.&lt;/p&gt;

&lt;p&gt;Without idempotency, a retry could send the same email twice, create duplicate tickets, or repeat a transaction.&lt;/p&gt;

&lt;p&gt;Every state-changing tool call should include a stable execution identifier or idempotency key.&lt;/p&gt;

&lt;h2&gt;
  
  
  Agent-specific failure modes
&lt;/h2&gt;

&lt;p&gt;A strong candidate should discuss:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Infinite planning loops&lt;/li&gt;
&lt;li&gt;Repeated tool calls&lt;/li&gt;
&lt;li&gt;Prompt injection inside retrieved content&lt;/li&gt;
&lt;li&gt;Tool hallucination&lt;/li&gt;
&lt;li&gt;Stale observations&lt;/li&gt;
&lt;li&gt;Excessive cost&lt;/li&gt;
&lt;li&gt;Partial workflow completion&lt;/li&gt;
&lt;li&gt;Conflicting actions&lt;/li&gt;
&lt;li&gt;Unauthorized data access&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The system should impose:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Maximum step counts&lt;/li&gt;
&lt;li&gt;Token budgets&lt;/li&gt;
&lt;li&gt;Time limits&lt;/li&gt;
&lt;li&gt;Per-tool permissions&lt;/li&gt;
&lt;li&gt;Human checkpoints&lt;/li&gt;
&lt;li&gt;Detailed audit logs&lt;/li&gt;
&lt;li&gt;Recovery or compensation workflows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;a href="https://www.designgurus.io/course/grokking-modern-ai-fundamentals" rel="noopener noreferrer"&gt;Grokking Modern AI Fundamentals&lt;/a&gt; course can provide additional background on agentic AI, planning, memory, and tool-based behavior.&lt;/p&gt;




&lt;h1&gt;
  
  
  Additional AI System Design Questions to Practice
&lt;/h1&gt;

&lt;p&gt;The four core questions cover much of the modern AI stack, but interviewers can frame the same concepts in narrower ways.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design an enterprise AI copilot
&lt;/h2&gt;

&lt;p&gt;Focus on tenant isolation, document permissions, RAG, conversation history, model routing, auditability, and data retention.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design a coding assistant
&lt;/h2&gt;

&lt;p&gt;Discuss repository indexing, code-aware chunking, low-latency suggestions, context selection, IDE integration, private-code protection, and evaluation of generated code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design an AI evaluation platform
&lt;/h2&gt;

&lt;p&gt;Cover dataset versioning, offline evaluation, human review, model comparison, prompt experiments, regression detection, and production feedback.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design a multi-model gateway
&lt;/h2&gt;

&lt;p&gt;Explain routing between internal and third-party models based on cost, quality, latency, privacy, context length, and availability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design a semantic-search platform
&lt;/h2&gt;

&lt;p&gt;Focus on ingestion, embeddings, vector indexes, hybrid retrieval, filtering, reranking, index updates, and relevance metrics.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design an AI safety and guardrails service
&lt;/h2&gt;

&lt;p&gt;Discuss policy versioning, input and output classification, prompt-injection detection, tool restrictions, personally identifiable information, appeals, and false-positive handling.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design a prompt-management platform
&lt;/h2&gt;

&lt;p&gt;Cover prompt templates, version control, experiments, rollout, rollback, tenant overrides, caching, and compatibility with changing model versions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design a multimodal assistant
&lt;/h2&gt;

&lt;p&gt;Add image, audio, and document ingestion, media storage, preprocessing, modality-specific models, content safety, and larger payload management.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Interviewers Look for in AI System Design Answers
&lt;/h1&gt;

&lt;p&gt;A weak answer places an LLM box in the center of a diagram and connects it to an API.&lt;/p&gt;

&lt;p&gt;A strong answer explains the system around the model.&lt;/p&gt;

&lt;p&gt;Interviewers want to see whether you can reason about:&lt;/p&gt;

&lt;h2&gt;
  
  
  End-to-end architecture
&lt;/h2&gt;

&lt;p&gt;Can you connect the client, application services, retrieval layer, model platform, storage, and observability systems?&lt;/p&gt;

&lt;h2&gt;
  
  
  Trade-offs
&lt;/h2&gt;

&lt;p&gt;Can you compare:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Larger models versus smaller models&lt;/li&gt;
&lt;li&gt;Quality versus latency&lt;/li&gt;
&lt;li&gt;Quality versus cost&lt;/li&gt;
&lt;li&gt;Long context versus retrieval&lt;/li&gt;
&lt;li&gt;Hosted APIs versus self-hosting&lt;/li&gt;
&lt;li&gt;Semantic retrieval versus keyword search&lt;/li&gt;
&lt;li&gt;Autonomy versus human control&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Reliability
&lt;/h2&gt;

&lt;p&gt;Can the system continue operating when a model, vector index, tool, region, or third-party provider is unavailable?&lt;/p&gt;

&lt;h2&gt;
  
  
  Evaluation
&lt;/h2&gt;

&lt;p&gt;Can you tell whether a new model or prompt actually improved the product?&lt;/p&gt;

&lt;h2&gt;
  
  
  Security
&lt;/h2&gt;

&lt;p&gt;Can you protect tenant data, prevent unauthorized retrieval, constrain tool use, and manage sensitive prompts?&lt;/p&gt;

&lt;h2&gt;
  
  
  Cost
&lt;/h2&gt;

&lt;p&gt;Can you estimate and control token usage, accelerator capacity, retrieval cost, storage, and third-party API spending?&lt;/p&gt;

&lt;p&gt;The model is only one component. Production readiness comes from the architecture surrounding it.&lt;/p&gt;




&lt;h1&gt;
  
  
  How to Prepare
&lt;/h1&gt;

&lt;p&gt;Candidates new to large-scale architecture should first learn the traditional foundations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.designgurus.io/course/grokking-system-design-fundamentals" rel="noopener noreferrer"&gt;Grokking System Design Fundamentals&lt;/a&gt; introduces the core building blocks behind scalable systems, including databases, caches, queues, replication, partitioning, and load balancing.&lt;/p&gt;

&lt;p&gt;The original &lt;a href="https://www.designgurus.io/course/grokking-the-system-design-interview" rel="noopener noreferrer"&gt;Grokking the System Design Interview&lt;/a&gt; applies those concepts to common interview problems and teaches a structured way to move from requirements to architecture and trade-offs.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://www.designgurus.io/course/system-design-interview-crash-course" rel="noopener noreferrer"&gt;System Design Interview Crash Course&lt;/a&gt; is useful for practicing a consistent interview framework across modern case studies, including a complete ChatGPT design problem.&lt;/p&gt;

&lt;p&gt;Engineers preparing for senior and staff-level discussions can continue with &lt;a href="https://www.designgurus.io/course/grokking-system-design-interview-ii" rel="noopener noreferrer"&gt;Advanced System Design Interview, Volume II&lt;/a&gt;, which emphasizes open-ended problems, failures, and defensible architectural decisions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.designgurus.io/course/grokking-scalable-systems-for-interviews" rel="noopener noreferrer"&gt;Grokking Scalable Systems for Interviews&lt;/a&gt; is a useful next step for strengthening scalability, observability, fault tolerance, and performance reasoning.&lt;/p&gt;

&lt;p&gt;For every AI design problem, practice three times:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Design the happy path.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Design for failure and overload.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Defend the quality, safety, and cost trade-offs.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That third pass is where most of the valuable interview discussion occurs.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Takeaway
&lt;/h1&gt;

&lt;p&gt;AI system design is not a replacement for traditional system design.&lt;/p&gt;

&lt;p&gt;It is a traditional system design combined with a new set of constraints.&lt;/p&gt;

&lt;p&gt;You still need to understand APIs, storage, caching, queues, partitioning, replication, security, observability, and fault tolerance.&lt;/p&gt;

&lt;p&gt;But you must now apply those concepts to systems with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Probabilistic outputs&lt;/li&gt;
&lt;li&gt;Expensive inference&lt;/li&gt;
&lt;li&gt;Streaming generation&lt;/li&gt;
&lt;li&gt;Vector retrieval&lt;/li&gt;
&lt;li&gt;Dynamic prompts&lt;/li&gt;
&lt;li&gt;Long-lived context&lt;/li&gt;
&lt;li&gt;External tools&lt;/li&gt;
&lt;li&gt;Model evaluation&lt;/li&gt;
&lt;li&gt;Safety requirements&lt;/li&gt;
&lt;li&gt;Human approval&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Start with four foundational problems:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Design ChatGPT.&lt;/li&gt;
&lt;li&gt;Design a RAG platform.&lt;/li&gt;
&lt;li&gt;Design an LLM inference service.&lt;/li&gt;
&lt;li&gt;Design an AI agent platform.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Master the request flow, deep dives, failure modes, and trade-offs behind each one.&lt;/p&gt;

&lt;p&gt;Once you can explain those systems clearly, most other AI system design questions become variations of the same underlying building blocks.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>rag</category>
      <category>chatgpt</category>
      <category>claude</category>
    </item>
    <item>
      <title>System Design Interview Questions by Level: Junior, Mid-Level, Senior, and Staff</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Thu, 25 Jun 2026 11:25:18 +0000</pubDate>
      <link>https://dev.to/arslan_ah/system-design-interview-questions-by-level-junior-mid-level-senior-and-staff-2m6h</link>
      <guid>https://dev.to/arslan_ah/system-design-interview-questions-by-level-junior-mid-level-senior-and-staff-2m6h</guid>
      <description>&lt;h1&gt;
  
  
  System Design Interview Questions by Level: Junior, Mid-Level, Senior, and Staff
&lt;/h1&gt;

&lt;p&gt;Not every system design interview evaluates the same thing.&lt;/p&gt;

&lt;p&gt;A junior engineer may be asked to design a URL shortener and explain why a cache would help. A mid-level engineer could receive the same question but be expected to estimate traffic, choose a database, and handle key collisions.&lt;/p&gt;

&lt;p&gt;A senior engineer may need to discuss multi-region deployment, consistency, failure recovery, and operational trade-offs. A staff engineer could be pushed further into migration strategy, organizational boundaries, cost, and the long-term evolution of the platform.&lt;/p&gt;

&lt;p&gt;The question may look identical. The expected answer is not.&lt;/p&gt;

&lt;p&gt;This is why preparing from one enormous, unstructured list of system design questions can be misleading. Candidates often spend time on problems that are far above or below the depth required for their target role.&lt;/p&gt;

&lt;p&gt;A better approach is to organize your preparation around the level you are targeting.&lt;/p&gt;

&lt;p&gt;This guide breaks system design interview questions into four groups:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Junior engineers&lt;/li&gt;
&lt;li&gt;Mid-level engineers&lt;/li&gt;
&lt;li&gt;Senior engineers&lt;/li&gt;
&lt;li&gt;Staff engineers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a broader collection covering every difficulty tier, see the complete pillar guide: &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m"&gt;64 System Design Interview Questions, Ranked From Easiest to Hardest&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The goal here is different. Instead of simply listing questions, we will examine what interviewers expect from candidates at each engineering level.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Changes as You Move Up the Engineering Ladder?
&lt;/h2&gt;

&lt;p&gt;System design interviews become harder with seniority, but not simply because the systems become larger.&lt;/p&gt;

&lt;p&gt;The most important change is the &lt;strong&gt;depth of reasoning expected from you&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A junior candidate is usually evaluated on whether they understand fundamental building blocks.&lt;/p&gt;

&lt;p&gt;A mid-level candidate must connect those building blocks into a scalable architecture.&lt;/p&gt;

&lt;p&gt;A senior candidate must anticipate failures, challenge assumptions, and defend architectural trade-offs.&lt;/p&gt;

&lt;p&gt;A staff candidate must think beyond the immediate system and consider its interaction with teams, platforms, migrations, business constraints, and long-term technical strategy.&lt;/p&gt;

&lt;p&gt;A simplified progression looks like this:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Level&lt;/th&gt;
&lt;th&gt;Primary expectation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Junior&lt;/td&gt;
&lt;td&gt;Understand the basic components and produce a workable design&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mid-level&lt;/td&gt;
&lt;td&gt;Build a scalable end-to-end system and explain major trade-offs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Senior&lt;/td&gt;
&lt;td&gt;Handle ambiguity, failures, correctness, and operational complexity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Staff&lt;/td&gt;
&lt;td&gt;Shape the problem, evaluate long-term consequences, and lead the design discussion&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Your preparation should reflect this progression.&lt;/p&gt;




&lt;h1&gt;
  
  
  Junior-Level System Design Interview Questions
&lt;/h1&gt;

&lt;p&gt;Junior engineers are not normally expected to design a globally distributed platform from first principles.&lt;/p&gt;

&lt;p&gt;Interviewers are more interested in whether you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clarify basic requirements.&lt;/li&gt;
&lt;li&gt;Identify the main entities.&lt;/li&gt;
&lt;li&gt;Define simple APIs.&lt;/li&gt;
&lt;li&gt;Choose reasonable storage.&lt;/li&gt;
&lt;li&gt;Understand caching and load balancing.&lt;/li&gt;
&lt;li&gt;Estimate basic traffic and storage.&lt;/li&gt;
&lt;li&gt;Explain how the system could scale beyond one server.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The best junior-level questions usually focus on one dominant concept.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Design TinyURL
&lt;/h2&gt;

&lt;p&gt;A URL shortener is one of the best starting points for system design preparation.&lt;/p&gt;

&lt;p&gt;The core workflow is simple:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A user submits a long URL.&lt;/li&gt;
&lt;li&gt;The system generates a short identifier.&lt;/li&gt;
&lt;li&gt;The identifier is stored with the original URL.&lt;/li&gt;
&lt;li&gt;Requests to the short URL are redirected.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A junior candidate should be able to discuss:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The API for creating and resolving links.&lt;/li&gt;
&lt;li&gt;Generating unique short keys.&lt;/li&gt;
&lt;li&gt;Handling collisions.&lt;/li&gt;
&lt;li&gt;Storing URL mappings.&lt;/li&gt;
&lt;li&gt;Caching frequently accessed links.&lt;/li&gt;
&lt;li&gt;Expiring links when necessary.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Do not overcomplicate the first version. Start with a single service and database, then explain how load balancers, replicas, and caches could be introduced as traffic increases.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/_TsJizByBvE"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Design Pastebin
&lt;/h2&gt;

&lt;p&gt;Pastebin extends the URL-shortening problem by adding larger content, expiration, and access control.&lt;/p&gt;

&lt;p&gt;Important questions include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Should paste content and metadata live together?&lt;/li&gt;
&lt;li&gt;How will pastes expire?&lt;/li&gt;
&lt;li&gt;How will private pastes be protected?&lt;/li&gt;
&lt;li&gt;Where should large text objects be stored?&lt;/li&gt;
&lt;li&gt;How can popular pastes be served quickly?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This problem teaches an important system design lesson: different types of data may require different storage strategies.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Design an API Rate Limiter
&lt;/h2&gt;

&lt;p&gt;A rate limiter controls how many requests a user or client can send during a given period.&lt;/p&gt;

&lt;p&gt;Junior candidates should understand the basic algorithms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fixed window&lt;/li&gt;
&lt;li&gt;Sliding window&lt;/li&gt;
&lt;li&gt;Token bucket&lt;/li&gt;
&lt;li&gt;Leaky bucket&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The interview is not only about naming an algorithm. You should explain where counters are stored, how limits are associated with users, and what response is returned when the limit is exceeded.&lt;/p&gt;

&lt;p&gt;A simple in-memory solution is acceptable initially. You can then introduce a shared store such as Redis when multiple application servers need access to the same counters.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Design a Unique ID Generator
&lt;/h2&gt;

&lt;p&gt;Distributed systems frequently need identifiers for users, orders, posts, messages, and transactions.&lt;/p&gt;

&lt;p&gt;The problem appears easy until several machines must generate IDs simultaneously.&lt;/p&gt;

&lt;p&gt;A junior-level discussion may compare:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Auto-incrementing database IDs&lt;/li&gt;
&lt;li&gt;Random UUIDs&lt;/li&gt;
&lt;li&gt;Timestamp-based identifiers&lt;/li&gt;
&lt;li&gt;Preallocated ID ranges&lt;/li&gt;
&lt;li&gt;Snowflake-style IDs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Focus on uniqueness first. Ordering, clock drift, and coordination can be introduced as deeper follow-up topics.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Design Typeahead Suggestions
&lt;/h2&gt;

&lt;p&gt;A typeahead service returns suggestions while a user is entering a search query.&lt;/p&gt;

&lt;p&gt;The design introduces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prefix lookup&lt;/li&gt;
&lt;li&gt;Tries and prefix indexes&lt;/li&gt;
&lt;li&gt;Popularity ranking&lt;/li&gt;
&lt;li&gt;Caching&lt;/li&gt;
&lt;li&gt;Latency requirements&lt;/li&gt;
&lt;li&gt;Updating trending queries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The most important lesson is that the system cannot scan every possible query after each keystroke. It needs a data structure or precomputed index that supports fast prefix retrieval.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Design an API Gateway
&lt;/h2&gt;

&lt;p&gt;An API gateway sits between clients and backend services.&lt;/p&gt;

&lt;p&gt;A foundational design should explain how it handles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Request routing&lt;/li&gt;
&lt;li&gt;Authentication&lt;/li&gt;
&lt;li&gt;Rate limiting&lt;/li&gt;
&lt;li&gt;Logging&lt;/li&gt;
&lt;li&gt;Response aggregation&lt;/li&gt;
&lt;li&gt;Protocol transformation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This question helps junior engineers understand how clients interact with a microservice architecture without calling dozens of internal services directly.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a Strong Junior Answer Looks Like
&lt;/h2&gt;

&lt;p&gt;A good junior-level answer does not need to include every distributed-systems technique.&lt;/p&gt;

&lt;p&gt;It should demonstrate a clear thought process:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clarify what the system must do.&lt;/li&gt;
&lt;li&gt;Define the main API operations.&lt;/li&gt;
&lt;li&gt;Choose a simple data model.&lt;/li&gt;
&lt;li&gt;Draw the initial architecture.&lt;/li&gt;
&lt;li&gt;Identify the likely bottleneck.&lt;/li&gt;
&lt;li&gt;Explain one or two ways the design could scale.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Candidates preparing for their first system design interview can begin with &lt;a href="https://www.designgurus.io/course/grokking-system-design-fundamentals" rel="noopener noreferrer"&gt;Grokking System Design Fundamentals&lt;/a&gt; and then progress to the original &lt;a href="https://www.designgurus.io/course/grokking-the-system-design-interview" rel="noopener noreferrer"&gt;Grokking the System Design Interview&lt;/a&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  Mid-Level System Design Interview Questions
&lt;/h1&gt;

&lt;p&gt;Mid-level engineers are expected to move beyond isolated components.&lt;/p&gt;

&lt;p&gt;Your design should include a complete flow from the client request to storage, processing, and delivery. You should recognize common bottlenecks without waiting for the interviewer to point them out.&lt;/p&gt;

&lt;p&gt;Interviewers may expect you to discuss:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read-heavy versus write-heavy workloads.&lt;/li&gt;
&lt;li&gt;Database partitioning.&lt;/li&gt;
&lt;li&gt;Replication.&lt;/li&gt;
&lt;li&gt;Cache placement and invalidation.&lt;/li&gt;
&lt;li&gt;Asynchronous processing.&lt;/li&gt;
&lt;li&gt;Message queues.&lt;/li&gt;
&lt;li&gt;Eventual consistency.&lt;/li&gt;
&lt;li&gt;Basic failure recovery.&lt;/li&gt;
&lt;li&gt;Trade-offs between different designs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The questions at this level often involve familiar consumer products.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Design Twitter
&lt;/h2&gt;

&lt;p&gt;The central challenge in Twitter is generating a user’s home timeline.&lt;/p&gt;

&lt;p&gt;Two common strategies are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fan-out on write:&lt;/strong&gt; When a user posts, the system pushes the post into followers’ timelines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fan-out on read:&lt;/strong&gt; When a user opens the application, the system retrieves recent posts from everyone they follow.&lt;/p&gt;

&lt;p&gt;Fan-out on write improves read latency but creates enormous write amplification for accounts with millions of followers. Fan-out on read avoids those writes but makes timeline retrieval more expensive.&lt;/p&gt;

&lt;p&gt;A strong mid-level candidate should recognize that a hybrid strategy may work best.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Design Instagram
&lt;/h2&gt;

&lt;p&gt;Instagram introduces media upload, processing, storage, and delivery.&lt;/p&gt;

&lt;p&gt;Your design should separate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Media metadata&lt;/li&gt;
&lt;li&gt;Original image or video files&lt;/li&gt;
&lt;li&gt;Derived formats and thumbnails&lt;/li&gt;
&lt;li&gt;Feed-generation data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Application servers should not repeatedly serve large media files. Object storage and a content delivery network are better suited for that workload.&lt;/p&gt;

&lt;p&gt;Other useful discussion areas include privacy, upload retries, feed generation, and handling popular posts.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Design Facebook Messenger or WhatsApp
&lt;/h2&gt;

&lt;p&gt;A messaging service requires more than storing messages.&lt;/p&gt;

&lt;p&gt;You should consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Persistent connections&lt;/li&gt;
&lt;li&gt;Message routing&lt;/li&gt;
&lt;li&gt;Delivery acknowledgments&lt;/li&gt;
&lt;li&gt;Offline delivery&lt;/li&gt;
&lt;li&gt;Conversation history&lt;/li&gt;
&lt;li&gt;Message ordering&lt;/li&gt;
&lt;li&gt;Retries and deduplication&lt;/li&gt;
&lt;li&gt;Multi-device synchronization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The phrase “exactly-once delivery” should be used carefully. In practice, messaging systems often combine at-least-once delivery with idempotency and deduplication.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Design Dropbox
&lt;/h2&gt;

&lt;p&gt;Dropbox tests both server-side and client-side reasoning.&lt;/p&gt;

&lt;p&gt;Important concepts include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Breaking files into chunks.&lt;/li&gt;
&lt;li&gt;Uploading only changed chunks.&lt;/li&gt;
&lt;li&gt;Deduplicating identical data.&lt;/li&gt;
&lt;li&gt;Synchronizing files across devices.&lt;/li&gt;
&lt;li&gt;Handling concurrent updates.&lt;/li&gt;
&lt;li&gt;Maintaining version history.&lt;/li&gt;
&lt;li&gt;Storing metadata separately from file content.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The client plays a significant role because it monitors local changes and communicates them efficiently to the server.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Design Uber
&lt;/h2&gt;

&lt;p&gt;Uber combines geospatial search with frequently changing state.&lt;/p&gt;

&lt;p&gt;The system needs to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Receive driver-location updates.&lt;/li&gt;
&lt;li&gt;Find available drivers near a rider.&lt;/li&gt;
&lt;li&gt;Match drivers with trips.&lt;/li&gt;
&lt;li&gt;Track trip state.&lt;/li&gt;
&lt;li&gt;Calculate estimated arrival times.&lt;/li&gt;
&lt;li&gt;Handle sudden regional demand spikes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A mid-level candidate should be comfortable discussing geohashes or another spatial partitioning technique, but the conversation should not end there. You must also explain how the location index stays current and how matching requests avoid conflicts.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Design Yelp or Nearby Friends
&lt;/h2&gt;

&lt;p&gt;This question focuses on finding entities within a geographic area.&lt;/p&gt;

&lt;p&gt;Potential approaches include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Geohashing&lt;/li&gt;
&lt;li&gt;Quadtrees&lt;/li&gt;
&lt;li&gt;Grid-based indexes&lt;/li&gt;
&lt;li&gt;Spatial database indexes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The design should account for uneven density. A geographic cell in a rural area may contain almost nothing, while a similarly sized cell in Manhattan may contain thousands of businesses or users.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Design Ticketmaster
&lt;/h2&gt;

&lt;p&gt;Ticketmaster introduces temporary reservations and strong correctness requirements.&lt;/p&gt;

&lt;p&gt;The system must prevent two customers from purchasing the same seat.&lt;/p&gt;

&lt;p&gt;Important topics include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Seat-locking mechanisms&lt;/li&gt;
&lt;li&gt;Reservation expiration&lt;/li&gt;
&lt;li&gt;Waiting rooms&lt;/li&gt;
&lt;li&gt;Handling flash traffic&lt;/li&gt;
&lt;li&gt;Payment failures&lt;/li&gt;
&lt;li&gt;Idempotent booking operations&lt;/li&gt;
&lt;li&gt;Releasing abandoned reservations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This question helps distinguish systems where eventual consistency is acceptable from systems where it could create serious business problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Design a Notification System
&lt;/h2&gt;

&lt;p&gt;A notification platform may deliver:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Push notifications&lt;/li&gt;
&lt;li&gt;Emails&lt;/li&gt;
&lt;li&gt;SMS messages&lt;/li&gt;
&lt;li&gt;In-app notifications&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A good architecture separates notification creation from delivery by placing events on queues. Independent workers can then process different channels.&lt;/p&gt;

&lt;p&gt;The system should also respect user preferences, retry temporary failures, prevent duplicates, and enforce provider-specific rate limits.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a Strong Mid-Level Answer Looks Like
&lt;/h2&gt;

&lt;p&gt;A strong mid-level candidate should be able to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Complete the end-to-end design.&lt;/li&gt;
&lt;li&gt;Estimate the dominant workload.&lt;/li&gt;
&lt;li&gt;Explain the main read and write paths.&lt;/li&gt;
&lt;li&gt;Select storage based on access patterns.&lt;/li&gt;
&lt;li&gt;Use queues for work that does not need to happen synchronously.&lt;/li&gt;
&lt;li&gt;Identify hotspots and single points of failure.&lt;/li&gt;
&lt;li&gt;Compare at least two possible approaches to the central problem.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The original &lt;a href="https://www.designgurus.io/course/grokking-the-system-design-interview" rel="noopener noreferrer"&gt;Grokking the System Design Interview&lt;/a&gt; is especially relevant at this stage because it combines system design fundamentals, recurring trade-offs, and classic interview problems.&lt;/p&gt;




&lt;h1&gt;
  
  
  Senior-Level System Design Interview Questions
&lt;/h1&gt;

&lt;p&gt;Senior candidates are expected to take ownership of the discussion.&lt;/p&gt;

&lt;p&gt;The interviewer may deliberately leave the prompt vague. Rather than asking for every requirement individually, you should identify the assumptions that materially affect the architecture.&lt;/p&gt;

&lt;p&gt;Senior interviews tend to emphasize:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Failure modes.&lt;/li&gt;
&lt;li&gt;Multi-region operation.&lt;/li&gt;
&lt;li&gt;Data consistency.&lt;/li&gt;
&lt;li&gt;Idempotency.&lt;/li&gt;
&lt;li&gt;Observability.&lt;/li&gt;
&lt;li&gt;Backpressure.&lt;/li&gt;
&lt;li&gt;Capacity planning.&lt;/li&gt;
&lt;li&gt;Operational complexity.&lt;/li&gt;
&lt;li&gt;Security and privacy.&lt;/li&gt;
&lt;li&gt;Cost-aware architecture.&lt;/li&gt;
&lt;li&gt;Migration and rollout strategies.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Simply drawing more boxes does not make an answer senior-level. Depth comes from anticipating what could go wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Design Google Docs
&lt;/h2&gt;

&lt;p&gt;Real-time collaborative editing requires multiple users to update the same document concurrently.&lt;/p&gt;

&lt;p&gt;The key problem is convergence: all clients must eventually agree on the same document state, even when operations arrive in different orders.&lt;/p&gt;

&lt;p&gt;A strong discussion may include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Operational transformation&lt;/li&gt;
&lt;li&gt;Conflict-free replicated data types&lt;/li&gt;
&lt;li&gt;Operation logs&lt;/li&gt;
&lt;li&gt;Document snapshots&lt;/li&gt;
&lt;li&gt;Cursor and presence updates&lt;/li&gt;
&lt;li&gt;Reconnection after network failure&lt;/li&gt;
&lt;li&gt;Version history&lt;/li&gt;
&lt;li&gt;Permission changes during a session&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Senior candidates should explain which updates require durability and which can be treated as temporary presence information.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Design ChatGPT
&lt;/h2&gt;

&lt;p&gt;Designing ChatGPT combines conventional application infrastructure with large-model inference.&lt;/p&gt;

&lt;p&gt;The product layer may require:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Authentication&lt;/li&gt;
&lt;li&gt;Conversation history&lt;/li&gt;
&lt;li&gt;Usage limits&lt;/li&gt;
&lt;li&gt;Billing&lt;/li&gt;
&lt;li&gt;Streaming responses&lt;/li&gt;
&lt;li&gt;Safety enforcement&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The model-serving layer introduces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GPU scheduling&lt;/li&gt;
&lt;li&gt;Request batching&lt;/li&gt;
&lt;li&gt;Model routing&lt;/li&gt;
&lt;li&gt;Token streaming&lt;/li&gt;
&lt;li&gt;Context management&lt;/li&gt;
&lt;li&gt;KV-cache management&lt;/li&gt;
&lt;li&gt;Capacity and cost control&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The interviewer may not expect a detailed explanation of model training. A strong candidate clearly defines the scope and focuses on the online serving system.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Design a Distributed Cache
&lt;/h2&gt;

&lt;p&gt;A distributed cache such as Redis introduces several difficult concerns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Partitioning&lt;/li&gt;
&lt;li&gt;Replication&lt;/li&gt;
&lt;li&gt;Eviction&lt;/li&gt;
&lt;li&gt;Expiration&lt;/li&gt;
&lt;li&gt;Cache invalidation&lt;/li&gt;
&lt;li&gt;Hot keys&lt;/li&gt;
&lt;li&gt;Cache stampedes&lt;/li&gt;
&lt;li&gt;Node failure&lt;/li&gt;
&lt;li&gt;Rebalancing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A senior candidate should discuss what happens during partial failure, not merely describe the happy path.&lt;/p&gt;

&lt;p&gt;For example, when an expired popular key receives thousands of simultaneous requests, those requests may all hit the database. Request coalescing, staggered expiration, and stale-while-revalidate are possible protections.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Design a Payment System
&lt;/h2&gt;

&lt;p&gt;Payments are dominated by correctness rather than raw scale.&lt;/p&gt;

&lt;p&gt;Important concepts include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Idempotency keys&lt;/li&gt;
&lt;li&gt;Immutable transaction records&lt;/li&gt;
&lt;li&gt;Double-entry ledgers&lt;/li&gt;
&lt;li&gt;Payment state machines&lt;/li&gt;
&lt;li&gt;Reconciliation&lt;/li&gt;
&lt;li&gt;Webhook retries&lt;/li&gt;
&lt;li&gt;Duplicate events&lt;/li&gt;
&lt;li&gt;Refunds and chargebacks&lt;/li&gt;
&lt;li&gt;Unknown transaction outcomes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A network timeout does not prove that a payment failed. The request may have succeeded while the response was lost. The architecture must preserve this uncertainty and resolve it safely.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Design Amazon S3
&lt;/h2&gt;

&lt;p&gt;An object-storage system must provide extraordinary durability while serving huge volumes of reads and writes.&lt;/p&gt;

&lt;p&gt;A senior-level design should address:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Object and bucket metadata&lt;/li&gt;
&lt;li&gt;Data partitioning&lt;/li&gt;
&lt;li&gt;Replication or erasure coding&lt;/li&gt;
&lt;li&gt;Checksums&lt;/li&gt;
&lt;li&gt;Multipart uploads&lt;/li&gt;
&lt;li&gt;Versioning&lt;/li&gt;
&lt;li&gt;Lifecycle management&lt;/li&gt;
&lt;li&gt;Corruption detection&lt;/li&gt;
&lt;li&gt;Background repair&lt;/li&gt;
&lt;li&gt;Hot partitions&lt;/li&gt;
&lt;li&gt;Regional failures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The metadata plane and object data plane should be considered separately.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Design a Metrics and Monitoring System
&lt;/h2&gt;

&lt;p&gt;Monitoring systems ingest large volumes of time-series data.&lt;/p&gt;

&lt;p&gt;Important concerns include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;High-throughput ingestion&lt;/li&gt;
&lt;li&gt;Metric labels and cardinality&lt;/li&gt;
&lt;li&gt;Time-based partitioning&lt;/li&gt;
&lt;li&gt;Downsampling&lt;/li&gt;
&lt;li&gt;Retention&lt;/li&gt;
&lt;li&gt;Aggregation&lt;/li&gt;
&lt;li&gt;Query performance&lt;/li&gt;
&lt;li&gt;Alert evaluation&lt;/li&gt;
&lt;li&gt;Late-arriving data&lt;/li&gt;
&lt;li&gt;Regional collection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One of the most important discussions is cardinality. A seemingly harmless label such as a unique user ID can produce an unsustainable number of time series.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Design a Code Deployment System
&lt;/h2&gt;

&lt;p&gt;A deployment platform coordinates changes across large fleets of machines or containers.&lt;/p&gt;

&lt;p&gt;A strong design should include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Build artifacts&lt;/li&gt;
&lt;li&gt;Deployment manifests&lt;/li&gt;
&lt;li&gt;Canary releases&lt;/li&gt;
&lt;li&gt;Blue-green deployments&lt;/li&gt;
&lt;li&gt;Health checks&lt;/li&gt;
&lt;li&gt;Progressive rollout&lt;/li&gt;
&lt;li&gt;Automated rollback&lt;/li&gt;
&lt;li&gt;Audit logs&lt;/li&gt;
&lt;li&gt;Configuration management&lt;/li&gt;
&lt;li&gt;Regional sequencing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The senior-level challenge is not merely deploying the new version. It is limiting the blast radius when that version is defective.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a Strong Senior Answer Looks Like
&lt;/h2&gt;

&lt;p&gt;Senior candidates should lead rather than follow.&lt;/p&gt;

&lt;p&gt;That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Narrowing an ambiguous problem.&lt;/li&gt;
&lt;li&gt;Prioritizing the most important quality attributes.&lt;/li&gt;
&lt;li&gt;Making assumptions explicit.&lt;/li&gt;
&lt;li&gt;Identifying failure scenarios before being prompted.&lt;/li&gt;
&lt;li&gt;Explaining operational consequences.&lt;/li&gt;
&lt;li&gt;Choosing the deep dive that best demonstrates judgment.&lt;/li&gt;
&lt;li&gt;Acknowledging where the design creates future complexity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Engineers targeting senior and L5/L6 roles can use &lt;a href="https://www.designgurus.io/course/grokking-system-design-interview-ii" rel="noopener noreferrer"&gt;Grokking the System Design Interview, Volume II&lt;/a&gt; for more advanced distributed-systems problems and deeper trade-off analysis.&lt;/p&gt;




&lt;h1&gt;
  
  
  Staff-Level System Design Interview Questions
&lt;/h1&gt;

&lt;p&gt;Staff-level interviews are not simply senior interviews with larger numbers.&lt;/p&gt;

&lt;p&gt;The candidate is expected to reason across systems, teams, and time horizons.&lt;/p&gt;

&lt;p&gt;A staff engineer should be able to discuss:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Platform boundaries.&lt;/li&gt;
&lt;li&gt;Ownership between teams.&lt;/li&gt;
&lt;li&gt;Incremental migrations.&lt;/li&gt;
&lt;li&gt;Build-versus-buy decisions.&lt;/li&gt;
&lt;li&gt;Long-term data models.&lt;/li&gt;
&lt;li&gt;Cross-region architecture.&lt;/li&gt;
&lt;li&gt;Compliance and security.&lt;/li&gt;
&lt;li&gt;Cost and organizational constraints.&lt;/li&gt;
&lt;li&gt;Standardization versus team autonomy.&lt;/li&gt;
&lt;li&gt;How the system evolves over several years.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The interviewer may care more about how you frame the problem than about the final diagram.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Design a Stock Exchange
&lt;/h2&gt;

&lt;p&gt;A stock exchange requires deterministic ordering, low latency, and strict correctness.&lt;/p&gt;

&lt;p&gt;The design should cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Order submission&lt;/li&gt;
&lt;li&gt;Sequencing&lt;/li&gt;
&lt;li&gt;Order books&lt;/li&gt;
&lt;li&gt;Matching engines&lt;/li&gt;
&lt;li&gt;Market-data distribution&lt;/li&gt;
&lt;li&gt;Persistence and replay&lt;/li&gt;
&lt;li&gt;Risk controls&lt;/li&gt;
&lt;li&gt;Failure recovery&lt;/li&gt;
&lt;li&gt;Auditability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Partitioning by financial instrument can improve scalability, but each order book needs a clear source of authority.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Design a Distributed Lock Manager
&lt;/h2&gt;

&lt;p&gt;Distributed locking introduces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Consensus&lt;/li&gt;
&lt;li&gt;Leases&lt;/li&gt;
&lt;li&gt;Session expiration&lt;/li&gt;
&lt;li&gt;Leader election&lt;/li&gt;
&lt;li&gt;Fencing tokens&lt;/li&gt;
&lt;li&gt;Split-brain prevention&lt;/li&gt;
&lt;li&gt;Clock and network uncertainty&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A staff candidate should understand why acquiring a lock is not enough. A paused or partitioned client might continue operating after its lease has expired. Fencing tokens can help downstream resources reject stale owners.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Design a Distributed Job Scheduler
&lt;/h2&gt;

&lt;p&gt;A global scheduler must trigger jobs at the correct time, distribute work, and recover from failures.&lt;/p&gt;

&lt;p&gt;Challenges include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sharding schedules.&lt;/li&gt;
&lt;li&gt;Leader election.&lt;/li&gt;
&lt;li&gt;Worker coordination.&lt;/li&gt;
&lt;li&gt;Duplicate execution.&lt;/li&gt;
&lt;li&gt;Missed schedules.&lt;/li&gt;
&lt;li&gt;Long-running jobs.&lt;/li&gt;
&lt;li&gt;Retries.&lt;/li&gt;
&lt;li&gt;Backpressure.&lt;/li&gt;
&lt;li&gt;Time-zone handling.&lt;/li&gt;
&lt;li&gt;Disaster recovery.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The candidate should distinguish between guaranteeing that a job is dispatched and guaranteeing that its business effect occurs only once.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Design Apache Kafka
&lt;/h2&gt;

&lt;p&gt;Kafka is best understood as a distributed append-only log rather than a conventional queue.&lt;/p&gt;

&lt;p&gt;A staff-level discussion may cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Partitioning&lt;/li&gt;
&lt;li&gt;Consumer groups&lt;/li&gt;
&lt;li&gt;Offset management&lt;/li&gt;
&lt;li&gt;Replication&lt;/li&gt;
&lt;li&gt;Leader election&lt;/li&gt;
&lt;li&gt;Retention&lt;/li&gt;
&lt;li&gt;Log compaction&lt;/li&gt;
&lt;li&gt;Rebalancing&lt;/li&gt;
&lt;li&gt;Delivery semantics&lt;/li&gt;
&lt;li&gt;Cross-region replication&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The design should also consider how Kafka would be operated as a shared organizational platform without allowing one workload to destabilize everyone else.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Explain Amazon Dynamo
&lt;/h2&gt;

&lt;p&gt;Dynamo provides a rich case study in availability-oriented storage.&lt;/p&gt;

&lt;p&gt;Core topics include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Consistent hashing&lt;/li&gt;
&lt;li&gt;Replication&lt;/li&gt;
&lt;li&gt;Quorum reads and writes&lt;/li&gt;
&lt;li&gt;Vector clocks&lt;/li&gt;
&lt;li&gt;Sloppy quorums&lt;/li&gt;
&lt;li&gt;Hinted handoff&lt;/li&gt;
&lt;li&gt;Read repair&lt;/li&gt;
&lt;li&gt;Merkle trees&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At staff level, do not just define these mechanisms. Explain why Dynamo chose them and which workloads are compatible with those trade-offs.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Explain Cassandra
&lt;/h2&gt;

&lt;p&gt;Cassandra combines Dynamo-inspired distribution with an LSM-tree-based storage engine.&lt;/p&gt;

&lt;p&gt;A strong discussion may include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Partition keys&lt;/li&gt;
&lt;li&gt;Tunable consistency&lt;/li&gt;
&lt;li&gt;Commit logs&lt;/li&gt;
&lt;li&gt;Memtables&lt;/li&gt;
&lt;li&gt;SSTables&lt;/li&gt;
&lt;li&gt;Bloom filters&lt;/li&gt;
&lt;li&gt;Compaction&lt;/li&gt;
&lt;li&gt;Tombstones&lt;/li&gt;
&lt;li&gt;Repair&lt;/li&gt;
&lt;li&gt;Hot partitions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The schema must be designed around queries. Poor partition-key selection can undermine an otherwise scalable architecture.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Explain Google File System and Bigtable
&lt;/h2&gt;

&lt;p&gt;These systems show how infrastructure components can be composed.&lt;/p&gt;

&lt;p&gt;Google File System is optimized around large files, sequential access, append-heavy workloads, and frequent machine failure.&lt;/p&gt;

&lt;p&gt;Bigtable builds a distributed, sorted storage abstraction while relying on other infrastructure for persistent storage and coordination.&lt;/p&gt;

&lt;p&gt;The broader staff-level lesson is that architecture is shaped by workload assumptions. A design that is excellent for one environment may be inappropriate for another.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a Strong Staff Answer Looks Like
&lt;/h2&gt;

&lt;p&gt;A staff-level candidate should be able to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reframe the prompt around business and technical priorities.&lt;/li&gt;
&lt;li&gt;Establish architectural principles.&lt;/li&gt;
&lt;li&gt;Identify the interfaces between major subsystems.&lt;/li&gt;
&lt;li&gt;Explain how multiple teams could own and evolve the system.&lt;/li&gt;
&lt;li&gt;Propose an incremental path rather than a risky rewrite.&lt;/li&gt;
&lt;li&gt;Compare technical complexity with operational and organizational costs.&lt;/li&gt;
&lt;li&gt;Recognize when the system should use an existing platform instead of building a new one.&lt;/li&gt;
&lt;li&gt;Discuss how the architecture behaves during rare but severe failures.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Staff interviews are less about producing the largest possible diagram and more about demonstrating durable technical judgment.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Same Question Can Be Asked at Every Level
&lt;/h1&gt;

&lt;p&gt;Consider the instruction:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Design a URL-shortening service.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A junior candidate may focus on the API, short-code generation, database schema, and cache.&lt;/p&gt;

&lt;p&gt;A mid-level candidate may add traffic estimates, partitioning, replication, expiration, analytics, and abuse prevention.&lt;/p&gt;

&lt;p&gt;A senior candidate may discuss global routing, multi-region consistency, disaster recovery, hot-key protection, observability, and safe migrations.&lt;/p&gt;

&lt;p&gt;A staff candidate may ask whether the organization should build a shared link-management platform, how several product teams would integrate with it, how privacy policies would be enforced, and how the service could migrate from an existing system without breaking billions of links.&lt;/p&gt;

&lt;p&gt;The prompt stayed the same.&lt;/p&gt;

&lt;p&gt;The evaluation level changed.&lt;/p&gt;

&lt;p&gt;This is why memorizing one “correct” architecture is not enough. Your answer must reflect the depth expected from the role.&lt;/p&gt;




&lt;h1&gt;
  
  
  How Many Questions Should You Practice?
&lt;/h1&gt;

&lt;p&gt;You do not need to complete every system design question ever published.&lt;/p&gt;

&lt;p&gt;A more effective preparation plan is:&lt;/p&gt;

&lt;h3&gt;
  
  
  Junior candidates
&lt;/h3&gt;

&lt;p&gt;Practice five to eight foundational problems deeply.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mid-level candidates
&lt;/h3&gt;

&lt;p&gt;Practice approximately ten to fifteen problems covering social feeds, messaging, file storage, geospatial search, booking, and notifications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Senior candidates
&lt;/h3&gt;

&lt;p&gt;Practice fifteen to twenty problems, with additional attention to payments, infrastructure, observability, collaboration, storage, and failure handling.&lt;/p&gt;

&lt;h3&gt;
  
  
  Staff candidates
&lt;/h3&gt;

&lt;p&gt;Practice fewer problems at greater depth. Add production case studies and distributed-systems papers to your preparation.&lt;/p&gt;

&lt;p&gt;The complete &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m"&gt;64-question system design roadmap&lt;/a&gt; can help you select problems that match your target level.&lt;/p&gt;

&lt;p&gt;For every problem, use three passes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Learn:&lt;/strong&gt; Study the architecture and central trade-offs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reconstruct:&lt;/strong&gt; Design the system again without looking at the solution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Defend:&lt;/strong&gt; Explain failures, alternatives, costs, and why your decisions fit the requirements.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The third pass is where interview readiness develops.&lt;/p&gt;




&lt;h1&gt;
  
  
  Choosing the Right System Design Preparation Path
&lt;/h1&gt;

&lt;p&gt;Your preparation resources should match your current level.&lt;/p&gt;

&lt;p&gt;Newer engineers may begin with &lt;a href="https://www.designgurus.io/course/grokking-system-design-fundamentals" rel="noopener noreferrer"&gt;Grokking System Design Fundamentals&lt;/a&gt; to build familiarity with scalability, databases, caching, replication, partitioning, messaging, and other architectural building blocks.&lt;/p&gt;

&lt;p&gt;Junior and mid-level candidates can continue with the original &lt;a href="https://www.designgurus.io/course/grokking-the-system-design-interview" rel="noopener noreferrer"&gt;Grokking the System Design Interview&lt;/a&gt;, which applies those concepts to classic interview questions.&lt;/p&gt;

&lt;p&gt;Senior and staff candidates should add &lt;a href="https://www.designgurus.io/course/grokking-system-design-interview-ii" rel="noopener noreferrer"&gt;Grokking the System Design Interview, Volume II&lt;/a&gt;, where the emphasis moves toward more complex distributed systems, deeper failure analysis, and defensible architectural decisions.&lt;/p&gt;

&lt;p&gt;Candidates working with a limited preparation window can also use the &lt;a href="https://www.designgurus.io/course/system-design-interview-crash-course" rel="noopener noreferrer"&gt;System Design Interview Crash Course&lt;/a&gt; as a structured review of system design frameworks and modern design problems.&lt;/p&gt;

&lt;p&gt;The broader &lt;a href="https://www.designgurus.io/system-design-interview" rel="noopener noreferrer"&gt;DesignGurus System Design Interview Guide&lt;/a&gt; can serve as a central reference for frameworks, concepts, questions, and study resources.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Takeaway
&lt;/h1&gt;

&lt;p&gt;The best system design preparation is not based on solving the greatest possible number of questions.&lt;/p&gt;

&lt;p&gt;It is based on practicing the right questions at the right depth.&lt;/p&gt;

&lt;p&gt;Junior engineers should build confidence with focused, single-concept systems.&lt;/p&gt;

&lt;p&gt;Mid-level engineers should learn to connect components into scalable end-to-end architectures.&lt;/p&gt;

&lt;p&gt;Senior engineers should anticipate failures, defend trade-offs, and account for operational complexity.&lt;/p&gt;

&lt;p&gt;Staff engineers should shape the problem, guide long-term architecture, and reason across systems, teams, and organizational constraints.&lt;/p&gt;

&lt;p&gt;As you move up the engineering ladder, the interviewer becomes less interested in whether you know a particular component and more interested in whether you can make sound decisions under uncertainty.&lt;/p&gt;

&lt;p&gt;That is the real progression from junior to staff-level system design.&lt;/p&gt;

</description>
      <category>distributedsystems</category>
      <category>systemdesign</category>
      <category>ai</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Must do system design interview questions required for each software engineering level.</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Sat, 09 May 2026 16:07:42 +0000</pubDate>
      <link>https://dev.to/arslan_ah/must-do-system-design-interview-questions-required-for-each-software-engineering-level-3b9</link>
      <guid>https://dev.to/arslan_ah/must-do-system-design-interview-questions-required-for-each-software-engineering-level-3b9</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m" class="crayons-story__hidden-navigation-link"&gt;64 System Design Interview Questions, Ranked From Easiest to Hardest&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/arslan_ah" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F34147%2F2974e0a5-f688-45b5-a4c9-5fa49c257854.jpg" alt="arslan_ah profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/arslan_ah" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Arslan Ahmad
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Arslan Ahmad
                
              
              &lt;div id="story-author-preview-content-3488973" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/arslan_ah" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F34147%2F2974e0a5-f688-45b5-a4c9-5fa49c257854.jpg" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Arslan Ahmad&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Apr 12&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m" id="article-link-3488973"&gt;
          64 System Design Interview Questions, Ranked From Easiest to Hardest
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/systemdesign"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;systemdesign&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/softwaredevelopment"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;softwaredevelopment&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/interview"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;interview&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/ai"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;ai&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;16&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            19 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
      <category>career</category>
      <category>interview</category>
      <category>softwareengineering</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>The 9 Things Engineers Get Wrong About the System Design Interview (and the 185 Articles I Wrote to Fix Them)</title>
      <dc:creator>Arslan Ahmad</dc:creator>
      <pubDate>Mon, 13 Apr 2026 08:38:14 +0000</pubDate>
      <link>https://dev.to/arslan_ah/the-9-things-engineers-get-wrong-about-the-system-design-interview-and-the-185-articles-i-wrote-to-22p1</link>
      <guid>https://dev.to/arslan_ah/the-9-things-engineers-get-wrong-about-the-system-design-interview-and-the-185-articles-i-wrote-to-22p1</guid>
      <description>&lt;p&gt;Every time I sit down to run a system design mock interview, the candidate fails for one of nine reasons.&lt;/p&gt;

&lt;p&gt;Not ten. Not seven. Nine.&lt;/p&gt;

&lt;p&gt;I've been doing this long enough — coaching engineers, running mocks, swapping debrief notes with hiring managers at Google, Meta, Amazon, Netflix, Microsoft, OpenAI, and a long tail of smaller companies — that the patterns have stopped surprising me. The same nine misconceptions show up in candidate after candidate, regardless of seniority. A junior at a startup makes the same mistakes as a staff engineer at a unicorn. Not the same magnitude, but the same shape.&lt;/p&gt;

&lt;p&gt;Over the years, I've written 185+ articles on DesignGurus.io and DEV Community trying to address these exact failure modes one at a time. This essay pulls all of them together, organized not by topic — that's the way I usually shelf them — but by the misconception each one actually exists to correct.&lt;/p&gt;

&lt;p&gt;If you're prepping for a &lt;strong&gt;system design interview&lt;/strong&gt; right now, this is the order I'd hand the articles to you in. Read each section. Ask yourself honestly whether the misconception applies to you. &lt;em&gt;Only then&lt;/em&gt; click into the posts. The goal isn't to read all 185. The goal is to read the ones that fix what's actually broken in your prep.&lt;/p&gt;

&lt;p&gt;One quick note on audience. I write for engineers from junior all the way up through staff, plus engineering managers. Almost every misconception below applies across the board, but where a particular section skews toward one group, I'll say so. Engineering managers especially: don't skip Section 9. The gap between EMs who pass design loops and EMs who don't is almost never about technical depth.&lt;/p&gt;

&lt;p&gt;Alright. Here are the nine.&lt;/p&gt;




&lt;h2&gt;
  
  
  Misconception #1: "It's a memorization test."
&lt;/h2&gt;

&lt;p&gt;This is the most common one, and the most expensive.&lt;/p&gt;

&lt;p&gt;Engineers walk in thinking the system design interview is a quiz: name three load balancing algorithms, define CAP theorem, list the four Vs of big data. They study it the way you'd study for a vocabulary test. Then they walk into the room, the interviewer says "design Twitter," and they freeze — because flash cards don't tell you how to start.&lt;/p&gt;

&lt;p&gt;The system design interview is not a quiz. It's a structured conversation that tests whether you can reason about ambiguity, gather requirements, make trade-offs out loud, and defend your decisions when challenged. The vocabulary matters — you can't have the conversation without the words — but the vocabulary is the floor, not the ceiling. What you actually need first is a &lt;em&gt;method&lt;/em&gt;. A repeatable approach you can fall back on when your brain goes blank.&lt;/p&gt;

&lt;p&gt;These are the articles that give you one.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/grokking-system-design-a-complete-roadmap-2026" rel="noopener noreferrer"&gt;Grokking System Design: A Complete Roadmap for 2026&lt;/a&gt; — If I could hand you a single starting point, this would be it.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/complete-system-design-roadmap-2025" rel="noopener noreferrer"&gt;2025 System Design Roadmap: From Beginner to Advanced&lt;/a&gt; — A second pass at the roadmap if you want a different angle on the same path.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/how-to-prepare-for-system-design-interview-2026" rel="noopener noreferrer"&gt;How to Prepare for System Design Interview in 2026&lt;/a&gt; — Concrete weekly cadence for engineers who don't know what "study" even looks like for this round.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/how-to-approach-system-design-question" rel="noopener noreferrer"&gt;How to Approach Any System Design Question&lt;/a&gt; — A universal opening framework that works on whatever prompt the interviewer lobs at you.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/your-seven-day-system-design-interview-prep-plan" rel="noopener noreferrer"&gt;Your 7-Day System Design Interview Prep Plan&lt;/a&gt; — For when your loop is one week away and panic is setting in.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/last-minute-system-design-prep-what-to-focus-on-right-now" rel="noopener noreferrer"&gt;Last-Minute System Design Prep&lt;/a&gt; — For when your loop is tomorrow morning.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/how-to-gather-requirements-in-system-design-interviews" rel="noopener noreferrer"&gt;How to Gather and Prioritize Requirements&lt;/a&gt; — The first five minutes of the interview, broken down so you don't waste them.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/complete-guide-sys-design" rel="noopener noreferrer"&gt;System Design Interview Prep Guide: 7 Steps&lt;/a&gt; — A clean seven-step framework for going from zero to ready.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/step-by-step-guide" rel="noopener noreferrer"&gt;System Design Interview Guide — 7 Steps to Ace It&lt;/a&gt; — The same seven steps, but mapped to what you do live in the room.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/arslan_ah/system-design-interviews-a-step-by-step-guide-39am"&gt;System Design Interviews: A Step-By-Step Guide&lt;/a&gt; — My Dev Community version of the same step-by-step framework.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/mastering-the-system-design-interview-complete-guide" rel="noopener noreferrer"&gt;Mastering the System Design Interview: A Complete Guide&lt;/a&gt; — A long-form guide for engineers who want one canonical reference.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/mastering-the-system-design-interview-landing-your-dream-job" rel="noopener noreferrer"&gt;Mastering the System Design Interview: Landing Your Dream Job&lt;/a&gt; — The companion piece focused on converting prep into outcomes.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-mastery-your-roadmap-to-acing-interviews" rel="noopener noreferrer"&gt;System Design Mastery: Your Roadmap to Acing Interviews&lt;/a&gt; — A more advanced roadmap aimed at senior+ candidates.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-interview-guide" rel="noopener noreferrer"&gt;Demystifying System Design Interviews&lt;/a&gt; — What's actually happening on the interviewer's side of the table.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/a-comprehensive-breakdown-of-systems-design-interviews" rel="noopener noreferrer"&gt;A Comprehensive Breakdown of Systems Design Interviews&lt;/a&gt; — The hidden rubric you're being graded on, made explicit.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/how-to-clear-system-design-interview" rel="noopener noreferrer"&gt;How To Clear System Design Interview: A Quick Guide&lt;/a&gt; — A ruthlessly compressed checklist for passing the round.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/sys-design-distinguishes" rel="noopener noreferrer"&gt;7 Tips to Stand Out in Your System Design Interview&lt;/a&gt; — How "pass" candidates become "strong hire" candidates.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/how-candidates-passed-faang-system-design-interviews" rel="noopener noreferrer"&gt;How 4 Candidates Passed FAANG System Design Interviews&lt;/a&gt; — Four real stories that will calm you down if you're spiraling.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Misconception #2: "I know what consistency means."
&lt;/h2&gt;

&lt;p&gt;You probably don't.&lt;/p&gt;

&lt;p&gt;Or — more precisely — you know the textbook definition but you can't actually distinguish strong from eventual consistency in a real design conversation, you can't explain when each is appropriate, and you'll mumble something about CAP theorem if you get pushed on it. I've seen this in candidates with eight years of experience.&lt;/p&gt;

&lt;p&gt;The fundamentals are called fundamentals because everything else stacks on top of them. If you can't speak fluently about consistency, caching, load balancing, hashing, rate limiting, idempotency, and back-of-the-envelope estimation, the rest of your prep is a house built on sand. This is the section to go deepest on, even if you think you already know this stuff. &lt;em&gt;Especially&lt;/em&gt; if you think you already know this stuff.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-interview-fundamentals" rel="noopener noreferrer"&gt;25 Fundamental System Design Concepts&lt;/a&gt; — The twenty-five-concept checklist I run through to gauge readiness.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/4-basic-pillars-of-system-design" rel="noopener noreferrer"&gt;4 Basic Pillars of System Design&lt;/a&gt; — Scalability, availability, reliability, performance — the four qualities you're scored on.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-algorithms" rel="noopener noreferrer"&gt;12 System Design Algorithms You Must Know&lt;/a&gt; — The dozen algorithms quietly powering most distributed systems.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/eventual-vs-strong-consistency" rel="noopener noreferrer"&gt;Eventual vs Strong Consistency&lt;/a&gt; — How to talk about consistency without sliding into academic jargon.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/consistency-patterns-distributed-systems" rel="noopener noreferrer"&gt;Consistency Patterns in Distributed Systems&lt;/a&gt; — A tour of the major consistency models and the situations each is built for.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-interview-basics-cap-vs-pacelc" rel="noopener noreferrer"&gt;CAP vs PACELC&lt;/a&gt; — Why senior interviewers have quietly upgraded from CAP to PACELC.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/load-balancing-algorithms-guide" rel="noopener noreferrer"&gt;Load Balancing Algorithms Guide&lt;/a&gt; — The algorithms living inside every load balancer, explained without theory bloat.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/complete-load-balancing-guide" rel="noopener noreferrer"&gt;Complete Load Balancer Guide 2026&lt;/a&gt; — The 2026 deep dive on load balancers in real production deployments.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/caching-system-design-interview" rel="noopener noreferrer"&gt;Mastering the Art of Caching&lt;/a&gt; — Cache layers, eviction strategies, and the pitfalls nobody warns juniors about.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/cache-invalidation-strategies" rel="noopener noreferrer"&gt;Cache Invalidation Strategies&lt;/a&gt; — The hardest problem in computer science, finally given a serious treatment.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/content-delivery-network-cdn-system-design-basics" rel="noopener noreferrer"&gt;CDN System Design Basics&lt;/a&gt; — When a CDN earns its place in your diagram and when it's just resume garnish.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/consistent-hashing-vs-traditional-hashing" rel="noopener noreferrer"&gt;Consistent Hashing vs Traditional Hashing&lt;/a&gt; — The hashing technique that quietly makes horizontal sharding even possible.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/grokking-rate-limiters" rel="noopener noreferrer"&gt;Grokking Rate Limiters&lt;/a&gt; — Token buckets, leaky buckets, and how to actually implement one on a whiteboard.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/grokking-webhooks" rel="noopener noreferrer"&gt;Grokking Webhooks&lt;/a&gt; — Why webhooks beat polling and how to design them so they don't blow up.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/grokking-system-design-events" rel="noopener noreferrer"&gt;Grokking Events in System Design&lt;/a&gt; — What the word "event" really means once you're inside an event-driven architecture.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/grokking-idempotency" rel="noopener noreferrer"&gt;Grokking Idempotency&lt;/a&gt; — The single key concept that keeps distributed systems from corrupting themselves.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/concurrency-vs-parallelism" rel="noopener noreferrer"&gt;Concurrency vs Parallelism&lt;/a&gt; — A distinction that more than half my mock candidates get wrong on the first try.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/sync-vs-async" rel="noopener noreferrer"&gt;Synchronous vs Asynchronous Communication&lt;/a&gt; — The hidden operational cost of going async, and when you should pay it anyway.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/stateless-vs-stateful" rel="noopener noreferrer"&gt;Stateless vs Stateful&lt;/a&gt; — The single biggest lever you have for horizontal scale.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/estimation-in-system-design-interviews" rel="noopener noreferrer"&gt;Mastering Estimation in System Design Interviews&lt;/a&gt; — How to do capacity math live without freezing or hand-waving.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/back-of-the-envelope-system-design-interview" rel="noopener noreferrer"&gt;Back-of-the-Envelope Estimation&lt;/a&gt; — The "numbers every programmer should know," updated for modern interviews.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/observer-vs-pub-sub-pattern" rel="noopener noreferrer"&gt;Observer vs Pub-Sub Pattern&lt;/a&gt; — Two patterns that look identical from a distance and behave nothing alike up close.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Misconception #3: "Database choice doesn't really matter."
&lt;/h2&gt;

&lt;p&gt;It's the entire interview.&lt;/p&gt;

&lt;p&gt;Walk through any "design X" question that ever gets asked, and you'll find the data layer is where the candidate either earns the offer or loses it. Sharding strategies, replication topology, indexing decisions, the SQL-versus-NoSQL fork — these aren't side topics. &lt;em&gt;They are the conversation.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I've watched too many candidates draw a beautiful service diagram and then wave vaguely at a cylinder labeled "DB" as if the storage layer were beneath their notice. It isn't. Senior interviewers spend half the round on data, and they grade you on how comfortable you are with the trade-offs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/postgresql-vs-mongodb-vs-dynamodb" rel="noopener noreferrer"&gt;PostgreSQL vs MongoDB vs DynamoDB&lt;/a&gt; — The three databases you'll be asked about most, compared honestly.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/no-slq-database" rel="noopener noreferrer"&gt;NoSQL Databases in System Design Interviews&lt;/a&gt; — A principled framework for when reaching for NoSQL is actually the right call.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/graph-database-neo4j" rel="noopener noreferrer"&gt;Graph Databases 101&lt;/a&gt; — The class of problem graph databases solve elegantly that relational ones can't.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/horizontally-scale-sql-databases" rel="noopener noreferrer"&gt;Why Horizontally Scaling SQL Is Hard&lt;/a&gt; — The structural reasons relational systems fight you when you try to scale them out.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/scaling-sql-databases" rel="noopener noreferrer"&gt;Scaling SQL Databases: 8 Challenges&lt;/a&gt; — The specific problems you'll hit when you push SQL past its comfort zone anyway.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/database-sharding-guide-2026" rel="noopener noreferrer"&gt;Complete Database Sharding Guide 2026&lt;/a&gt; — Every sharding strategy worth knowing, plus how each one fails.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/database-replication" rel="noopener noreferrer"&gt;Database Replication Fundamentals&lt;/a&gt; — Master-slave, multi-master, and quorum replication, demystified.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/data-replication-strategies-system-design" rel="noopener noreferrer"&gt;Data Replication Strategies I Wish I'd Known Earlier&lt;/a&gt; — The replication patterns I had to learn the hard way.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/b-tree-vs-hash-tree-vs-r-tree" rel="noopener noreferrer"&gt;B-Tree vs Hash vs R-Tree&lt;/a&gt; — Three index structures and the workloads each is built for.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/database-index-hash-vs-tree-vs-bitmap" rel="noopener noreferrer"&gt;Database Indexing Demystified&lt;/a&gt; — A second take on indexing that brings bitmap indexes into the picture.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/database-indexing" rel="noopener noreferrer"&gt;Grokking Database Indexing&lt;/a&gt; — Why indexes make queries fast, derived from first principles.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/normalization-vs-denormalization" rel="noopener noreferrer"&gt;Normalization vs Denormalization&lt;/a&gt; — The eternal "it depends" question, finally given some actual rules.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/acid-database-transaction" rel="noopener noreferrer"&gt;ACID &amp;amp; Database Transactions 101&lt;/a&gt; — Four letters every candidate should be able to riff on without notice.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/database-fragmentation" rel="noopener noreferrer"&gt;From UUID to Snowflake&lt;/a&gt; — Why distributed ID generation is its own surprisingly deep topic.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/change-data-capture" rel="noopener noreferrer"&gt;Change Data Capture 101&lt;/a&gt; — How CDC pipelines keep downstream systems coherent without dual writes.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/redis-guide" rel="noopener noreferrer"&gt;Ultimate Guide to Redis in System Design&lt;/a&gt; — Redis explained through the lens of how it actually shows up in interviews.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Misconception #4: "Fast and scalable mean the same thing."
&lt;/h2&gt;

&lt;p&gt;They don't.&lt;/p&gt;

&lt;p&gt;A fast system can be impossible to scale. A scalable system can have terrible per-request latency. They are orthogonal qualities, optimized with different techniques, and conflating them is one of the cleanest tells that a candidate hasn't built distributed systems in production. When an interviewer asks "how would you make this faster?" and you start talking about adding more servers, you've revealed the gap.&lt;/p&gt;

&lt;p&gt;This section covers the trade-off conversations that show up in every senior loop: scale versus latency, availability versus consistency, build versus buy, performance versus cost. Master these and you'll start sounding like an engineer who's actually shipped something at scale.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/grokking-system-design-scalability" rel="noopener noreferrer"&gt;Grokking Scalability in System Design&lt;/a&gt; — The core mental models for thinking about scale from day one.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/scaling-101-comprehensive-learning-for-large-system-designs" rel="noopener noreferrer"&gt;Scaling 101&lt;/a&gt; — A thorough primer on scaling real-world systems beginning to end.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/large-scale-system-design-questions-guide" rel="noopener noreferrer"&gt;Large-Scale System Design Questions&lt;/a&gt; — Walkthroughs of questions that operate at billion-user scale.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/high-availability-system-design-basics" rel="noopener noreferrer"&gt;High Availability — 15 Strategies&lt;/a&gt; — Fifteen concrete patterns for keeping a system up through failure.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/autoscaling-strategies" rel="noopener noreferrer"&gt;Autoscaling Strategies&lt;/a&gt; — The autoscaling approaches that hold up when traffic actually spikes.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/5-best-leader-election-algorithms" rel="noopener noreferrer"&gt;5 Best Leader Election Algorithms&lt;/a&gt; — The leader-election algorithms senior interviewers expect you to know on sight.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/best-5-ways-to-reduce-latency" rel="noopener noreferrer"&gt;Best 5 Ways To Reduce Latency&lt;/a&gt; — Five concrete levers when "make it faster" lands on your desk.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/long-tail-latency" rel="noopener noreferrer"&gt;Demystifying Long-Tail Latency&lt;/a&gt; — Why p99 is the number that matters and how to actually attack it.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/read-heavy-vs-write-heavy" rel="noopener noreferrer"&gt;Read-Heavy vs Write-Heavy Workloads&lt;/a&gt; — How to shape your architecture around your read-write ratio.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/10-system-design-challenges-2025" rel="noopener noreferrer"&gt;Top 10 System Design Challenges&lt;/a&gt; — The hardest problems in modern distributed systems engineering.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/top-12-system-design-trade-offs-every-interviewee-must-master-in-2025" rel="noopener noreferrer"&gt;Top 12 System Design Trade-offs&lt;/a&gt; — The trade-offs that surface in nearly every senior loop.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-trade-offs-in-2025-a-step-by-step-framework-for-faang-interviews" rel="noopener noreferrer"&gt;System Design Trade-offs Framework&lt;/a&gt; — A framework for talking through trade-offs the way a senior engineer would.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/complex-system-design-tradeoffs" rel="noopener noreferrer"&gt;Navigating Complex System Design Trade-Offs&lt;/a&gt; — Advanced trade-off analysis for staff-level conversations.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/buy-vs-build" rel="noopener noreferrer"&gt;The Buy vs Build Decision&lt;/a&gt; — How to frame the off-the-shelf-versus-build-it-yourself question convincingly.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Misconception #5: "An API is just an API."
&lt;/h2&gt;

&lt;p&gt;Tell me you haven't done a system design interview without telling me you haven't done a system design interview.&lt;/p&gt;

&lt;p&gt;Modern interviews — especially at companies that ship a lot of services — care a lot about how those services talk to each other. Choosing REST versus GraphQL versus gRPC isn't a stylistic preference; it's a load-bearing architectural decision. The differences between a load balancer, a reverse proxy, and an API gateway aren't trivia; they're three different places to put cross-cutting concerns, and interviewers will probe whether you know the difference.&lt;/p&gt;

&lt;p&gt;If your last meaningful API design conversation was about whether to use PUT or PATCH, this section is for you.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/http2-vs-http1" rel="noopener noreferrer"&gt;HTTP/2 vs HTTP/1.1&lt;/a&gt; — The protocol upgrades that genuinely move the needle on performance.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/udp-vs-tcp" rel="noopener noreferrer"&gt;TCP vs UDP&lt;/a&gt; — When UDP is the right call and when TCP is non-negotiable.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/cookies-vs-sessions" rel="noopener noreferrer"&gt;Cookies vs Sessions 101&lt;/a&gt; — Web session management for engineers who never properly learned the basics.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/when-you-type-url" rel="noopener noreferrer"&gt;What Happens When You Type a URL?&lt;/a&gt; — The classic warm-up question, walked through end to end.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/what-is-an-api-application-programming-interface" rel="noopener noreferrer"&gt;What is an API?&lt;/a&gt; — A first-principles definition for engineers who've used APIs without ever defining one.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/what-is-restful-api" rel="noopener noreferrer"&gt;Understanding RESTful APIs&lt;/a&gt; — What "RESTful" means in interviews versus how it gets butchered in production.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/10-best-api-design-practices" rel="noopener noreferrer"&gt;10 Best API Design Practices&lt;/a&gt; — Ten habits that mark the difference between a junior and senior API designer.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/api-design-checklist" rel="noopener noreferrer"&gt;The API Design Checklist&lt;/a&gt; — The mental checklist senior engineers run through before writing any endpoint.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/rest-graphql-grpc-system-design" rel="noopener noreferrer"&gt;REST vs GraphQL vs gRPC&lt;/a&gt; — A head-to-head on the three API paradigms competing for your design.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/8-rest-api-interview-questions-every-developer-should-know" rel="noopener noreferrer"&gt;8 REST API Interview Questions&lt;/a&gt; — The REST-flavored questions that keep cycling back through interviews.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/mastering-the-api-interview-common-questions-and-expert-answers" rel="noopener noreferrer"&gt;Mastering the API Interview&lt;/a&gt; — A deep dive on the API-focused round if your target company runs one.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/load-balancer-reverse-proxy-api-gateway" rel="noopener noreferrer"&gt;Load Balancer vs Reverse Proxy vs API Gateway&lt;/a&gt; — Three boxes that look identical and serve very different purposes.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/rabbitmq-kafka-activemq-system-design" rel="noopener noreferrer"&gt;RabbitMQ vs Kafka vs ActiveMQ&lt;/a&gt; — The three message brokers you'll be asked about, head-to-head.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/kafka-streams-apache-flink-apache-storm" rel="noopener noreferrer"&gt;Kafka Streams vs Flink vs Storm&lt;/a&gt; — The major stream processing engines, compared by what they're actually good at.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/network-timeouts-and-errors" rel="noopener noreferrer"&gt;Defensive Coding for Network Timeouts&lt;/a&gt; — The defensive patterns that prevent local failures from cascading into outages.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/message-patterns" rel="noopener noreferrer"&gt;Grokking Messaging Patterns&lt;/a&gt; — Queues, Pub/Sub, and event streams — the three workhorses of distributed comms.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Misconception #6: "Microservices are obviously the right answer."
&lt;/h2&gt;

&lt;p&gt;They're obviously the right answer the way a chainsaw is obviously the right tool for opening a letter.&lt;/p&gt;

&lt;p&gt;I've lost count of the number of candidates who reach for microservices reflexively when asked to design even modestly sized systems. They name-drop service meshes, mention Kubernetes for no clear reason, and end up with diagrams that have more boxes than the actual product would have users in its first year.&lt;/p&gt;

&lt;p&gt;A senior engineer knows when &lt;em&gt;not&lt;/em&gt; to use microservices. A senior engineer can defend a monolith. A senior engineer can articulate what SOA actually was, what each style's failure modes look like in production, and when "boring" is the right answer. This section will get you there.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/monolithic-service-oriented-microservice-architecture" rel="noopener noreferrer"&gt;Monolithic vs Microservices vs SOA&lt;/a&gt; — A fair comparison of the three major architectural styles.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/understanding-top-10-software-architecture-patterns" rel="noopener noreferrer"&gt;Top 10 Software Architecture Patterns&lt;/a&gt; — The ten patterns every senior engineer should be able to name and apply.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/10-myths-about-microservices-architecture" rel="noopener noreferrer"&gt;10 Myths About Microservices&lt;/a&gt; — The myths that push teams into microservices for all the wrong reasons.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/10-common-microservices-anti-patterns" rel="noopener noreferrer"&gt;10 Common Microservices Anti-Patterns&lt;/a&gt; — The anti-patterns I see most often in real production codebases.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/19-essential-microservices-patterns-for-system-design-interviews" rel="noopener noreferrer"&gt;19 Essential Microservices Patterns&lt;/a&gt; — Nineteen patterns worth keeping in active vocabulary.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/essential-software-design-principles-you-should-know-before-the-interview" rel="noopener noreferrer"&gt;Essential Software Design Principles (SOLID)&lt;/a&gt; — SOLID via real examples instead of canned definitions.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/object-oriented-programming-oop" rel="noopener noreferrer"&gt;Beginner's Guide to Object-Oriented Programming&lt;/a&gt; — An OOP refresher for engineers who came up through other paradigms.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/kubernetes-ultimate-guide" rel="noopener noreferrer"&gt;The Ultimate Kubernetes Guide for System Design&lt;/a&gt; — Kubernetes from a system design lens, not a DevOps one.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/virtual-machines-vs-containers" rel="noopener noreferrer"&gt;Virtual Machines vs Containers&lt;/a&gt; — VMs and containers, explained without the cloud-vendor marketing.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/a-beginners-guide-to-distributed-systems" rel="noopener noreferrer"&gt;A Beginner's Guide to Distributed Systems&lt;/a&gt; — A friendly on-ramp to thinking distributed-first.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/distributed-system-design-guide-for-beginners" rel="noopener noreferrer"&gt;Distributed System Design Guide for Beginners&lt;/a&gt; — Concepts and patterns for engineers building their first distributed system.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/apache-zookeeper-architecture-system-design" rel="noopener noreferrer"&gt;Apache ZooKeeper's Architecture&lt;/a&gt; — A look at how ZooKeeper holds distributed state together.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/idempotency-in-distributed-systems" rel="noopener noreferrer"&gt;Idempotency 101: Fault-Tolerant Distributed Systems&lt;/a&gt; — A production-grade treatment of idempotency in distributed contexts.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/arslan_ah/how-to-use-consistent-hashing-in-a-system-design-interview-33ge"&gt;How to Use Consistent Hashing in a System Design Interview&lt;/a&gt; — Applying consistent hashing live in an interview, walked through.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Misconception #7: "I've memorized 'design Twitter,' I'm fine."
&lt;/h2&gt;

&lt;p&gt;You're not.&lt;/p&gt;

&lt;p&gt;The case studies you'll find in this section are not scripts to memorize. They're worked examples of a &lt;em&gt;thinking process&lt;/em&gt; — and the goal is to internalize the process, not the answer. If your interviewer asks you to design Twitter and you regurgitate a memorized solution, a sharp interviewer will immediately pivot — &lt;em&gt;"OK, now make it work for live video instead of text"&lt;/em&gt; — and you'll be flailing again because you never learned to think, only to recite.&lt;/p&gt;

&lt;p&gt;The right way to use this section: read each case study once for ideas, then close the tab and design the same system from scratch on a blank piece of paper. Compare. The gap between your version and mine is your study plan for the next day.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/how-to-design-instagram-in-system-design-interview" rel="noopener noreferrer"&gt;How to Design Instagram&lt;/a&gt; — A worked walkthrough of the Instagram design question.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/design-social-media-news-feed" rel="noopener noreferrer"&gt;How to Design a Social Media News Feed&lt;/a&gt; — Designing a scalable news feed from first principles.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/url-shortening" rel="noopener noreferrer"&gt;How to Design a URL Shortener Service&lt;/a&gt; — The classic URL shortener, solved end to end.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/arslan_ah/system-design-interview-question-designing-a-url-shortening-service-4029"&gt;URL Shortener — Dev Community Version&lt;/a&gt; — A second take on the same problem from a slightly different angle.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/design-web-crawler" rel="noopener noreferrer"&gt;How to Design a Web Crawler&lt;/a&gt; — Designing a distributed crawler the way you'd actually build one.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/build-a-search-engine" rel="noopener noreferrer"&gt;How to Build a Search Engine&lt;/a&gt; — How search engines actually get built, from crawler to ranker.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/design-recommendation-system" rel="noopener noreferrer"&gt;How to Design a Recommendation System&lt;/a&gt; — The architecture behind Netflix-style recommendations.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/design-cloud-storage-service" rel="noopener noreferrer"&gt;How to Design a Cloud Storage Service&lt;/a&gt; — Designing Dropbox or Google Drive, including the parts most writeups skip.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/design-chat-application" rel="noopener noreferrer"&gt;How to Design a Real-Time Chat Application&lt;/a&gt; — Designing WhatsApp or Slack from scratch.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/design-real-time-editor" rel="noopener noreferrer"&gt;How to Design a Real-Time Collaborative Editor&lt;/a&gt; — How the Google Docs collaboration model actually works under the hood.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/design-video-conferencing-system" rel="noopener noreferrer"&gt;How to Design a Video Conferencing System&lt;/a&gt; — The architectural choices behind Zoom-style calls.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/ride-sharing-service" rel="noopener noreferrer"&gt;How to Design a Ride Sharing Service&lt;/a&gt; — Designing Uber end to end without hand-waving over geospatial.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/design-ticketing-system" rel="noopener noreferrer"&gt;Designing an E-Ticketing System&lt;/a&gt; — A ticketing system that survives flash-sale traffic.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/design-scalable-e-commerce-platform" rel="noopener noreferrer"&gt;Design a Scalable E-Commerce Platform&lt;/a&gt; — A modern e-commerce architecture built for scale from day one.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/design-parking-system" rel="noopener noreferrer"&gt;Designing a Parking System&lt;/a&gt; — The classic OOD parking lot question, answered properly.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/top-10-system-design-interview-questions-and-answers" rel="noopener noreferrer"&gt;10 Must-Do System Design Interview Questions&lt;/a&gt; — My ten must-do questions with full solutions.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-interview-questions-to-crack-your-next-faang-interview" rel="noopener noreferrer"&gt;64+ System Design Interview Questions&lt;/a&gt; — The full canonical question list, grouped by theme.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/arslan_ah/64-system-design-interview-questions-ranked-from-easiest-to-hardest-260m"&gt;64 Questions Ranked by Difficulty&lt;/a&gt; — The same set, ranked from easiest to hardest.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/50-advanced-system-design-interview-questions" rel="noopener noreferrer"&gt;50 Advanced System Design Questions&lt;/a&gt; — Fifty harder questions calibrated for senior and staff loops.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Misconception #8: "An interview is an interview."
&lt;/h2&gt;

&lt;p&gt;Companies vary wildly in what they actually grade.&lt;/p&gt;

&lt;p&gt;Google's bar is mostly about depth and rigor — they want you reasoning from first principles and acknowledging what you don't know. Amazon weaves leadership principles through every technical answer. Meta cares about product judgment alongside system judgment, and actually runs two different design rounds depending on the role. Netflix wants pragmatism and ownership. OpenAI is its own beast right now and changes faster than any blog post can keep up with.&lt;/p&gt;

&lt;p&gt;If you're prepping with a generic curriculum and then walking into a specific company's loop without tuning, you're leaving offers on the table. Pick your target. Study the rubric.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/faang-system-design-interviews-strategies-from-experts" rel="noopener noreferrer"&gt;FAANG System Design Interviews — Strategies from Real Experts&lt;/a&gt; — Strategies straight from people who've sat on both sides.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/mastering-the-faang-interview-the-ultimate-guide-for-software-engineers" rel="noopener noreferrer"&gt;Mastering the FAANG Interview&lt;/a&gt; — The complete guide to the entire FAANG loop, not just design.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/whats-the-best-way-to-prepare-for-faang-interviews-in-2025" rel="noopener noreferrer"&gt;FAANG Interviews in 2025: What Changed&lt;/a&gt; — What shifted in FAANG loops last year and how to adapt your prep.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-interviews-at-google-meta-amazon" rel="noopener noreferrer"&gt;Google, Amazon, and Meta Compared&lt;/a&gt; — How the three biggest companies differ in how they actually run the design round.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/google-system-design-interview-questions-ultimate-guide" rel="noopener noreferrer"&gt;Google System Design Interview Questions&lt;/a&gt; — Google's favorite questions with sample answers.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/google-system-design-interview-prep" rel="noopener noreferrer"&gt;Google System Design Secrets&lt;/a&gt; — Insider notes on Google's specific scoring habits.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/how-to-pass-google-system-design-interview" rel="noopener noreferrer"&gt;Pass Google System Design as a Non-Programmer&lt;/a&gt; — Yes, PMs and TPMs can clear this round — here's the playbook.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-interview-amazon" rel="noopener noreferrer"&gt;Amazon System Design Interview: 5 Sample Questions&lt;/a&gt; — Five Amazon-flavored questions worked through.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/amazon-system-design-mock-interview-preparation-guide" rel="noopener noreferrer"&gt;Amazon System Design Mock Interview Prep&lt;/a&gt; — How to run a mock that actually mirrors Amazon's loop.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/amazon-interview-questions-guide" rel="noopener noreferrer"&gt;Amazon Interview Questions: Ultimate Guide&lt;/a&gt; — The complete Amazon prep guide, including leadership principles.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/meta-system-design-interview-questions" rel="noopener noreferrer"&gt;Meta System Design Interview Questions&lt;/a&gt; — Meta's design questions with structured solutions.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/meta-system-design-vs-product-design" rel="noopener noreferrer"&gt;Meta System Design vs Product Design&lt;/a&gt; — How to tell Meta's two different design rounds apart.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/mastering-metas-product-design-interview" rel="noopener noreferrer"&gt;Mastering Meta's Product Design Interview&lt;/a&gt; — A complete guide to Meta's product architecture round.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/mastering-the-meta-technical-screen-a-comprehensive-guide-for-senior-software-engineers" rel="noopener noreferrer"&gt;Mastering the Meta Technical Screen&lt;/a&gt; — A thorough walkthrough of Meta's screen for senior candidates.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/all-you-need-to-know-about-the-meta-interview" rel="noopener noreferrer"&gt;All You Need to Know About the Meta Interview&lt;/a&gt; — A complete overview of Meta's hiring loop.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/how-to-ace-the-meta-engineering-manager-interview-process" rel="noopener noreferrer"&gt;How to Ace the Meta Engineering Manager Interview&lt;/a&gt; — The Meta EM loop, broken down by round.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/netflix-system-design-interview-questions-guide" rel="noopener noreferrer"&gt;Netflix System Design Interview Questions&lt;/a&gt; — Netflix's design questions with the context they're usually asked in.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/microsoft-system-design-interview-questions" rel="noopener noreferrer"&gt;Microsoft System Design Interview Questions&lt;/a&gt; — Microsoft's rubric and most-asked questions.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/openai-system-design-interview-questions" rel="noopener noreferrer"&gt;OpenAI System Design Interview Questions&lt;/a&gt; — The questions to expect when interviewing at OpenAI.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/tesla-system-design-interview-questions" rel="noopener noreferrer"&gt;Tesla System Design Interview Questions&lt;/a&gt; — How Tesla's design questions diverge from the FAANG mold.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/salesforce-system-design-mock-interview" rel="noopener noreferrer"&gt;Salesforce System Design Mock Interview&lt;/a&gt; — A mock built around Salesforce's actual loop.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/the-essential-guide-to-acing-the-paypal-software-engineer-interview" rel="noopener noreferrer"&gt;Acing the PayPal Software Engineer Interview&lt;/a&gt; — A deep dive on PayPal's interview process.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Misconception #9: "Coding and behavioral don't matter for senior roles."
&lt;/h2&gt;

&lt;p&gt;They might matter more.&lt;/p&gt;

&lt;p&gt;I have watched far more senior engineers fail FAANG loops on behavioral rounds than on system design. The math is brutal: you can ace four out of five rounds and still get a no-hire because one interviewer didn't believe your "tell me about a time you disagreed with your manager" story. Coding rounds, similarly, do not get easier as you climb the ladder — they get harder, because the bar shifts from "can you solve it" to "can you solve it cleanly while explaining your trade-offs out loud."&lt;/p&gt;

&lt;p&gt;This section is the reminder that the design round is one slice of a longer loop, and the candidates who get offers are the ones who prep all of it. Don't skip these because they aren't "the fun part." They're often the part that decides the offer.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/dont-just-leetcode" rel="noopener noreferrer"&gt;Don't Just LeetCode — Follow Coding Patterns&lt;/a&gt; — Why pattern-based prep beats raw LeetCode volume every time.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/coding-patterns-for-tech-interviews" rel="noopener noreferrer"&gt;Ultimate Coding Patterns Cheat Sheet&lt;/a&gt; — The cheat sheet I hand to every candidate I mentor.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/top-lc-patterns" rel="noopener noreferrer"&gt;10 Top LeetCode Patterns for FAANG&lt;/a&gt; — The ten patterns that unlock most FAANG coding questions.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/arslan_ah/top-leetcode-patterns-for-faang-coding-interviews-1on4"&gt;Top LeetCode Patterns — Dev Community Version&lt;/a&gt; — The same breakdown from a slightly different angle.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/arslan_ah/20-essential-coding-patterns-to-ace-your-next-coding-interview-32a3"&gt;20 Essential Coding Patterns&lt;/a&gt; — Twenty patterns that cover the vast majority of coding interview territory.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/5-algorithms-every-developer-should-know-to-clear-coding-interviews-in-2024" rel="noopener noreferrer"&gt;5 Essential Algorithms for Coding Interviews&lt;/a&gt; — The five algorithms worth committing to memory.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/top-20-coding-questions-to-pass-google-interview" rel="noopener noreferrer"&gt;Top 20 Coding Questions for the Google Interview&lt;/a&gt; — Twenty Google-favorite coding questions.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/coding-interview-mistakes-to-avoid" rel="noopener noreferrer"&gt;10 Coding Interview Mistakes to Avoid&lt;/a&gt; — The mistakes I see candidates repeat over and over.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/arslan_ah/the-ultimate-strategy-to-preparing-for-the-coding-interview-3ace"&gt;The Ultimate Strategy for Coding Interview Prep&lt;/a&gt; — My complete approach to preparing for coding rounds.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/arslan_ah/grokking-leetcode-a-smarter-way-to-prepare-for-coding-interviews-5d9d"&gt;Grokking LeetCode — A Smarter Way to Prepare&lt;/a&gt; — A smarter alternative to grinding until you drop.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/arslan_ah/key-steps-to-prepare-for-a-software-engineer-interview-52ll"&gt;Key Steps to Prepare for a Software Engineer Interview&lt;/a&gt; — The core steps to structure your prep from day one.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/software-engineer-interview-preparation-complete-guide-tips" rel="noopener noreferrer"&gt;Software Engineer Interview Preparation: Complete Guide&lt;/a&gt; — An end-to-end SE interview prep guide.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/the-roadmap-to-clearing-technical-interview-in-2024" rel="noopener noreferrer"&gt;The Roadmap to Clearing Technical Interviews in 2025&lt;/a&gt; — A full roadmap for technical interview prep.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/tech-interview-preparation-bootcamp" rel="noopener noreferrer"&gt;12 Weeks Tech Interview Preparation Bootcamp&lt;/a&gt; — A structured twelve-week bootcamp plan.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/all-you-need-to-know-about-an-interview-bootcamp" rel="noopener noreferrer"&gt;All You Need to Know About an Interview Bootcamp&lt;/a&gt; — What to expect from a structured bootcamp and who actually benefits.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/behavioral-interviews-at-faang" rel="noopener noreferrer"&gt;Behavioral Interviews at FAANG&lt;/a&gt; — What FAANG interviewers are really listening for in behavioral rounds.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/faang-behavioral-interview-guide" rel="noopener noreferrer"&gt;FAANG Behavioral Interview Guide&lt;/a&gt; — A thorough behavioral prep guide for FAANG loops.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/how-to-craft-compelling-behavioral-interview-stories" rel="noopener noreferrer"&gt;How to Craft Compelling Behavioral Interview Stories&lt;/a&gt; — A storytelling framework that turns flat answers into memorable ones.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/culture-fit-questions" rel="noopener noreferrer"&gt;Culture Fit in Tech Companies&lt;/a&gt; — What "culture fit" actually means to hiring committees.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/soft-skills-for-software-engineering-interview" rel="noopener noreferrer"&gt;Soft Skills for Software Engineering Interviews&lt;/a&gt; — The soft skills that quietly carry the most weight.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/software-engineer-survival-kit-2026" rel="noopener noreferrer"&gt;Software Engineer Survival Kit 2026&lt;/a&gt; — The skills I'd focus on now to stay relevant through the AI era.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/what-skills-should-junior-programmers-have-in-the-ai-period" rel="noopener noreferrer"&gt;Skills Junior Developers Need in the AI Era&lt;/a&gt; — What junior engineers should focus on as the field shifts under them.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/job-hunting-in-2024-is-linkedins-open-to-work-badge-your-secret-weapon" rel="noopener noreferrer"&gt;Job Hunting in 2025: LinkedIn's 'Open to Work' Badge&lt;/a&gt; — Whether the Open to Work badge actually helps your search.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/3-technologies-that-will-shape-the-future" rel="noopener noreferrer"&gt;3 Technologies That Will Shape the Future&lt;/a&gt; — My take on three technologies quietly reshaping the field right now.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Reference Shelf
&lt;/h2&gt;

&lt;p&gt;A handful of pieces that don't fit cleanly into any single misconception but are worth keeping bookmarked. Cheat sheets, course reviews, recommended papers, tools, and meta-essays on the discipline.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-cheat-sheet" rel="noopener noreferrer"&gt;The Ultimate System Design Cheat Sheet (2026)&lt;/a&gt; — The current version of the most-saved cheat sheet on the site.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-cheat-sheet-for-senior-engineer" rel="noopener noreferrer"&gt;System Design Cheat Sheet for Senior Engineers&lt;/a&gt; — A one-page reference tuned specifically for senior-level expectations.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-interview-pdf" rel="noopener noreferrer"&gt;System Design Interview PDF&lt;/a&gt; — A downloadable roadmap and checklist for offline prep.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-primer-the-ultimate-guide" rel="noopener noreferrer"&gt;System Design Primer: The Ultimate Guide&lt;/a&gt; — A reference primer on every term you'll need to know.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-tutorial-for-beginners" rel="noopener noreferrer"&gt;System Design Tutorial for Beginners (2025)&lt;/a&gt; — A tutorial that builds intuition through worked examples.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-concepts-for-beginners" rel="noopener noreferrer"&gt;System Design 101 — Beginner's Guide&lt;/a&gt; — The absolute first-timer introduction to the vocabulary.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-interview-guide-for-beginners" rel="noopener noreferrer"&gt;System Design Interview Guide for Beginners&lt;/a&gt; — A gentler ramp for engineers with no distributed systems background.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-interview-guide-2025" rel="noopener noreferrer"&gt;System Design Interview Guide 2025&lt;/a&gt; — A current top-to-bottom guide for FAANG-style design rounds.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/system-design-interview-faqs" rel="noopener noreferrer"&gt;Top System Design Interview FAQs&lt;/a&gt; — Straight answers to the questions candidates ask me on repeat.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/sys-design-papers" rel="noopener noreferrer"&gt;7 Must-Read System Design Papers&lt;/a&gt; — The foundational papers every senior candidate should have read.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/top-7-tools-for-creating-system-design-diagrams" rel="noopener noreferrer"&gt;Top 7 Tools for Creating System Design Diagrams&lt;/a&gt; — The diagramming tools I actually use when teaching.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/best-system-design-courses-for-beginners" rel="noopener noreferrer"&gt;Best System Design Courses for Beginners&lt;/a&gt; — A comparison of the entry-level options on the market.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/navigating-the-best-system-design-courses-for-coding-interviews" rel="noopener noreferrer"&gt;Navigating the Best System Design Courses&lt;/a&gt; — How to pick a course that actually matches your level and target.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/what-is-grokking-the-system-design-interview-a-complete-guide" rel="noopener noreferrer"&gt;What Is Grokking the System Design Interview?&lt;/a&gt; — A full tour of the flagship course for readers deciding if it fits them.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/grokking-system-design-interview-to-ace-faang" rel="noopener noreferrer"&gt;How to Use Grokking System Design Interview to Ace FAANG&lt;/a&gt; — Tactics for getting maximum value out of the course.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/is-grokking-system-design-course-worth-it" rel="noopener noreferrer"&gt;Is Grokking the System Design Interview Worth It?&lt;/a&gt; — An honest self-review for readers weighing the decision.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/grokking-the-system-design-interview-5-lessons" rel="noopener noreferrer"&gt;Grokking the System Design Interview — 5 Lessons&lt;/a&gt; — Five hard-won lessons from years of teaching this material.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/highscalability-vs-designgurus" rel="noopener noreferrer"&gt;HighScalability.com vs DesignGurus.io&lt;/a&gt; — A fair comparison of two popular resources and how they complement each other.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/why-practicing-system-design-is-crucial-for-software-engineers" rel="noopener noreferrer"&gt;Why Practicing System Design Is Crucial&lt;/a&gt; — Why this is a long-term career skill, not just interview theater.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.designgurus.io/blog/sys-design-for-data-scientists" rel="noopener noreferrer"&gt;Is System Design Important for Data Scientists?&lt;/a&gt; — Why data folks should care about system design too.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How to Actually Use This Guide
&lt;/h2&gt;

&lt;p&gt;A few last notes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One misconception at a time.&lt;/strong&gt; Don't open all nine sections at once. Pick the one that bites you hardest, work through those articles in sequence, do the exercises in your head as you go, and only then move on. Engineers who spread their attention across all nine misconceptions in parallel make about a third of the progress they'd make working serially.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practice harder than you read.&lt;/strong&gt; The single biggest mistake in interview prep is consuming material instead of producing it. After every case study, close the tab and design the same system on paper. After every fundamentals article, try to explain the concept to an imaginary junior engineer in three sentences. Your gaps will show up almost immediately, and they'll be far more useful than another article would have been.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trust the misconception framing.&lt;/strong&gt; I organized this post around mistakes rather than topics deliberately. Engineers who frame their prep around weaknesses improve faster than engineers who frame it around coverage. &lt;em&gt;"Read every database article"&lt;/em&gt; is a tempting goal because it's measurable, but it doesn't actually correct what's broken in your performance. &lt;em&gt;"I freeze when asked about consistency, so I'm spending three days on Section 2 until I can talk about it cold"&lt;/em&gt; — that does.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Come back when you've cleared the loop.&lt;/strong&gt; I've kept this list updated for years specifically because engineers who land offers write to tell me which articles helped and which were missing. If you make it through and break in, please send me that note. Those messages are why I keep writing this stuff in the first place.&lt;/p&gt;

&lt;p&gt;Good luck. You've got this.&lt;/p&gt;

</description>
      <category>distributedsystems</category>
      <category>interview</category>
      <category>softwareengineering</category>
      <category>systemdesign</category>
    </item>
  </channel>
</rss>
