LeetCode Solutions Explained: 475 Problems by Pattern

Every solution here walks from the problem statement to the brute force, then to the optimal approach, with a dry run, the time and space complexity, the mistakes people make and code that passed our test runner. The problems are grouped by the DSA pattern they teach, easiest first, so you can work through one pattern at a time. The full catalogue is on the DSA patterns pages and the DSA sheet.

Most searched

Solutions by pattern

Array/Matrix Manipulation Patterns (35)

Linked List Manipulation Patterns (17)

Two Pointers (37)

Sliding Window (32)

Binary Search Patterns (26)

Stack Patterns (29)

String Manipulation Patterns (16)

Heap (Priority Queue) Patterns (26)

Tree Traversal Patterns (DFS & BFS) (39)

Graph Traversal Patterns (DFS & BFS) (66)

Greedy Patterns (23)

Backtracking Patterns (24)

Dynamic Programming (DP) Patterns (56)

Bit Manipulation Patterns (13)

Design Patterns (36)