LeetCode Problems List: All 3,000, Organised by Pattern

This library holds a page for every one of the 3,000 problems on LeetCode. 2,690 of them carry a complete Python solution with a worked example, a step-by-step explanation and the time and space complexity of the approach. The problems are LeetCode's; the solutions, the grouping and the explanations are ours.

Problem numbers are a poor way to study, because the number tells you nothing about how the problem is solved. So the library is organised the way the problems are actually solved: 22 patterns, each with the technique written out, a Python template you can adapt, and every problem in the corpus that the pattern applies to. If you would rather follow a known plan, the five curated study lists cover 285 distinct problems between them.

Problems
3,000
With a full solution
2,690
Patterns
22
Topics
60

Browse by pattern

A pattern is the shape of the solution, and it transfers: once the sliding window is in your hands, every problem about a contiguous subarray becomes the same problem with different bookkeeping. Each hub below explains the technique, gives a Python template, states the complexity, and lists every problem in the library it applies to.

Sliding Window116 problemsCollapse a nested loop over every subarray into a single pass with two indices.Topological Sort32 problemsOrder a set of tasks so that every dependency comes before the thing that needs it.Monotonic Stack225 problemsAnswer "what is the next greater element" for every position in one pass.Stack194 problemsWhen the most recent unresolved thing is the one that matters, use a stack.Union-Find83 problemsMerge groups and ask whether two things are connected, both in near-constant time.Two Pointers201 problemsUse the order already in the input to discard half the search space at every step.Binary Search254 problemsHalve the search space each step — over an array, or over the answer itself.Dynamic Programming481 problemsDefine a state, write the transition, and stop recomputing the same subproblem.Backtracking105 problemsBuild candidates one choice at a time and abandon a branch the moment it cannot work.Depth-First Search366 problemsFollow one path to its end before trying the next — the default way to explore a graph.Breadth-First Search233 problemsExpand outward level by level, so the first time you arrive is the shortest way.Prefix Sum157 problemsPrecompute running totals once so any range query becomes a single subtraction.Heap / Priority Queue163 problemsKeep only the best k elements, or always pull the smallest, in log time.Greedy346 problemsTake the locally best option every time — when you can prove that never costs you later.Linked List75 problemsRewire pointers in place, with a dummy head and a saved next to keep it safe.Tree Traversal225 problemsChoose the order — preorder, inorder, postorder, level — and the problem solves itself.Trie49 problemsStore a set of words by their shared prefixes so lookups cost the length of the word.Bit Manipulation194 problemsUse XOR, masks and the low-bit trick to replace whole data structures with an integer.Matrix and Grid216 problemsTreat a 2-D grid as a graph whose neighbours are the four adjacent cells.Hash Map709 problemsTrade memory for time: remember what you have seen so the second pass never happens.Sorting401 problemsSpend O(n log n) once to buy an ordering that makes the rest of the problem trivial.Math and Number Theory485 problemsFind the closed form, the invariant, or the modular identity — and skip the loop entirely.

Curated study lists

Five well-known selections, none of them ours. We reproduce each list by problem number, say how many of its entries are in this library and how many of those carry a full solution, and link every one to its page here.

Browse by difficulty

760 Easy · 1,579 Medium · 661 Hard. Difficulty is LeetCode's own rating, carried through unchanged.

Browse by topic

LeetCode's own tags, which are coarser than the patterns above but are what the problem set is officially classified by. The 60 tags with at least eight problems each have a page; see all topics.

Stuck on the one you get asked

Stealth Interview is a desktop app for macOS and Windows. It reads the coding problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer is saying — while staying invisible to screen sharing.