Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Pattern Recognition for Algorithms

This guide starts from one habit I want for every problem I come across. See a problem, and before any code, say which pattern it belongs to and why. NeetCode 250 is my reference for which patterns to cover, but the problems worked through here can come from anywhere. Knowing what an algorithm does is the easier half. The harder half is the specific signal in a problem statement that makes the right one come to mind.

The Decision Tree page is where to start with a problem cold. It asks a small number of questions about the statement and narrows down which pattern to open first. Each chapter after it goes deep on one pattern, split into three pages that follow one order, recognize, write, practice.

Asking the Right Questions is the page I care about most. It works through five problems, reading each statement for the words that give the pattern away and the logic that confirms it. It contains no code and no analysis of running time, only the logic that takes a statement to a pattern, including how to tell the pattern apart from its closest neighbors.

Implementation answers how the code looks once the pattern is known. These are the skeletons worth knowing from memory, so that recognizing the pattern is the only hard part left and writing it becomes mechanical.

Examples works through problems one at a time, with the reasoning and the code together. Some reframe the problem first, and some are not on NeetCode 250 at all, since a pattern’s difficulty range is wider than any one list.

Hashing, Two Pointers, Sliding Window, Binary Search, and Stack are written so far. More patterns follow the same shape as they get written.