Learning Resources
DSA, SQL & System Design Guides
The sheets tell you what to solve. These tell you how the thing works — one guide per topic, written to be read once and then used as a reference, not one thin page per question.
DSA Patterns
The recurring shapes behind interview problems — what each pattern is, when it applies, the template that solves it, and the mistakes that cost people the round.
Backtracking
3 minChoose, recurse, un-choose. One template generates every subset, permutation and combination — pruning is what makes it fast.
Breadth First Search (BFS)
3 minA queue, a visited set, and level-by-level expansion — the shortest path on any unweighted graph.
Bitwise XOR
4 minFour algebraic properties turn 'find the unpaired number' into a one-line O(1)-space scan.
Cyclic Sort (Index-Based)
3 minWhen the values are 1..n, the array is its own hash map — swap each value home and read off what is missing.
Design Data Structure
3 minEvery answer is two structures combined — a hash map for lookup plus something that maintains order.
Depth First Search (DFS)
3 minGo deep, backtrack, repeat — the pattern behind islands, flood fill, and every connectivity question.
Dynamic Programming
4 minDefine the state, write the recurrence, memoise, then tabulate. Five families cover almost every DP question asked.
Fast and Slow Pointer
4 minTwo pointers at different speeds. Detects cycles, finds middles, and locates duplicates in constant space.
Graphs
4 minTopological sort, Dijkstra, union-find and MST — which one a question needs, and the template for each.
Greedy
3 minTake the best local choice and never reconsider — when you can prove that choice is safe.
K-way Merge
3 minA heap holding one candidate per list — the smallest overall is always the heap root.
Reversal of Linked List (In-place)
2 minThree pointers, one pass, no extra memory — and the dummy node that makes the sublist variants tractable.
Matrix Manipulation
3 minRotation is transpose plus reverse, spiral is four shrinking boundaries, and a sorted grid is a 1-D binary search.
Modified Binary Search
4 minOne boundary template, then the two hard variants: rotated arrays, and searching the answer space instead of the input.
Monotonic Stack
4 minA stack kept in sorted order answers every 'next greater element' question in one O(n) pass.
Overlapping Intervals
3 minSort by start, then merge in one pass — plus the heap and sweep-line variants for counting concurrent intervals.
Prefix Sum
3 minPrecompute running totals once, answer any range query in O(1) — and count target-sum subarrays in one pass.
Sliding Window
7 minTurn an O(n²) scan of every subarray into one O(n) pass — and learn to spot the problems where that works.
Top 'K' Elements
3 minKeep a size-K heap of the opposite type — min-heap for largest, max-heap for smallest. O(n log k), not O(n log n).
Trees
4 minFour traversals, one recursion template, and the two BST facts that answer half the questions.
Two Heaps
3 minSplit the data at the median — max-heap below, min-heap above. The answer is always at the two tops.
Two Pointers
3 minOne pointer at each end, converging. Turns the O(n²) pair search into a single sorted pass.
SQL
Query topics as they actually come up in interviews — joins, window functions, CTEs and the analytics patterns built on them, each with runnable queries.
Aggregation, GROUP BY and HAVING
3 minGROUP BY, HAVING, and the conditional-aggregation trick that answers half of all reporting questions.
CASE, Pivoting and Unpivoting
3 minCASE inside an aggregate is the portable pivot — rows become columns without any vendor-specific syntax.
CTEs and Recursive CTEs
3 minName your intermediate steps with WITH — then use the recursive form to walk hierarchies and generate sequences.
Date and Time Functions
3 minTruncate to group, add intervals to shift, and always use half-open ranges on timestamps.
INSERT, UPDATE, DELETE and DDL
4 minChanging data and schema safely — including the DELETE/TRUNCATE/DROP distinction that gets asked in every SQL interview.
Finding and Removing Duplicates
3 minGROUP BY HAVING to find them, ROW_NUMBER to delete all but one — and what to do when there is no primary key.
WHERE, Filtering and Pattern Matching
4 minEvery row filter, plus the two traps that silently return wrong rows: NOT IN with NULLs, and functions on indexed columns.
Gaps, Islands and Streaks
3 minThe row-number difference trick that turns consecutive runs, streaks and missing dates into one grouping problem.
SQL JOINs
3 minEvery join type, the ON-versus-WHERE rule that silently breaks LEFT JOINs, and the self-join for hierarchies.
NULL Handling
3 minNULL is 'unknown', not 'empty' — and that one distinction explains every surprising result it produces.
Indexes, Query Performance and Full-Text Search
4 minWhy a query is slow: index structure, the leftmost-prefix rule, sargable predicates, and how to read EXPLAIN.
SELECT, DISTINCT, ORDER BY and LIMIT
3 minThe clauses every query starts with — and the logical execution order that explains why aliases work in some places and not others.
Set Operations
3 minStacking result sets: UNION vs UNION ALL, plus INTERSECT and EXCEPT and how to fake them where they are missing.
String and Numeric Functions
3 minSlicing text and rounding numbers — including the integer-division trap that silently returns 0.
Subqueries and EXISTS
3 minScalar, correlated and derived subqueries — plus when EXISTS is the right answer and when a JOIN is.
Window Functions
3 minAggregate without collapsing rows — ranking, running totals, and comparing each row to its neighbours.
System Design
Design problems worked end to end: requirements, back-of-envelope numbers, the architecture, and the trade-offs an interviewer will push on.
Design ChatGPT
4 minGPU capacity is the scarce resource — continuous batching, KV caching and streaming are how you spend it well.
Design Google Docs
4 minA session server per document holding the authoritative state — plus OT or CRDTs to reconcile concurrent edits.
Design Google Drive
3 minContent-addressed chunks give dedup and delta sync for free — the metadata service is where the real design lives.
Design Google Maps
4 minPre-rendered tiles, a partitioned road graph with precomputed shortcuts, and live traffic folded into edge weights.
Design a Hotel Booking System
4 minInventory per room-type per night, and the concurrency control that stops two people buying the last room.
Design Instagram
3 minPhoto pipeline into blob storage and a CDN, hybrid feed fanout, and stories as TTL'd content.
Design a Key-Value Store
4 minConsistent hashing, quorum replication, and the CAP trade-off made concrete — the foundational distributed systems question.
Design LeetCode
3 minThe hard part is running untrusted code safely — everything else is a queue and a leaderboard.
Design a Distributed Message Queue
4 minA partitioned append-only log with consumer-managed offsets — plus what each delivery guarantee actually costs.
Design Netflix
4 minA finite catalogue encoded once and pushed to CDN appliances inside ISPs — the opposite problem to YouTube.
Design a News Feed System
4 minFanout on write, fanout on read, and the hybrid that handles celebrities — the core trade-off in social system design.
Design a Rate Limiter
4 minToken bucket in Redis, atomic counters, and the distributed-state problem that makes this question interesting.
Design Reddit
4 minTime-decayed ranking, nested comment trees with materialised paths, and vote counters that survive a viral post.
Design a Stock Exchange
4 minA single-threaded matching engine over an in-memory order book — the one design where sharding is the wrong answer.
Design TikTok
4 minA feed built from a recommendation model rather than a follow graph — which inverts the usual social design.
Design Tinder
4 minPrecomputed candidate decks, a swipe store optimised for one query, and atomic mutual-match detection.
Design TinyURL
4 minBase62 over a distributed counter, a cache in front of a key-value store, and the 301-vs-302 decision.
Design Twitter
3 minTimeline fanout with a celebrity carve-out, a sharded tweet store, and streaming trends.
Design Uber
4 minHigh-frequency location writes, cell-based proximity search, and a matching loop that must not double-assign a driver.
Design a Web Crawler
4 minThe URL frontier is the whole design — priority for what to crawl next, politeness for not overwhelming any host.
Design WhatsApp
4 minPersistent connections plus a session registry, an inbox per user, and the three-tick delivery state machine.
Design YouTube
3 minChunked upload, a parallel transcoding pipeline, adaptive bitrate over a CDN — and why the CDN is the system.
Design Chess (LLD)
4 minPolymorphic pieces, two-phase move validation, and the special rules that expose whether your model is real.
Design a Collaborative Editor (LLD)
4 minThe transform function, worked through concretely — and why CRDTs make character identity the answer instead.
Design a Dating App (LLD)
4 minA filter chain for eligibility, a canonical match key, and the safety rules that belong in the domain model.
Design a Food Delivery App (LLD)
3 minThree actors, one order state machine, and a pricing pipeline that composes instead of branching.
Design a Music Streaming Service (LLD)
4 minA player state machine plus a queue whose shuffle and repeat behaviours are strategies, not flags.
Design a Notification Engine (LLD)
4 minOne request, many channels — strategy for delivery, a preference layer, and idempotent retries.
Design a Payment Gateway (LLD)
4 minIdempotency keys, an explicit state machine and a double-entry ledger — the three things money systems cannot do without.
Design a Quick Commerce App (LLD)
4 minDark stores, reserved inventory and a 10-minute clock — the constraint that makes this different from food delivery.
Design Snake and Ladder (LLD)
3 minSnakes and ladders are the same thing — one Jump abstraction, one lookup map, and the design collapses.
Design Tic Tac Toe (LLD)
3 minThe warm-up machine-coding round — judged on the O(1) win check and whether your design generalises to N×N.