01Chapter 1: Why Start with Brute ForceWhen you face a new algorithmic problem, it is tempting to go straight for the clever solution: the hash map trick, the dynamic programming table, the two-pointer sweep. This chapter argues for a different first move. Write the simplest solution that is obviously correct, the one that tries every po7 min read
02Chapter 2: Defining What You Are Searching ThroughThis chapter assumes you can write Python functions, loops, and generators, and that you know lists and dictionaries. You should also be able to read simple Big-O expressions such as O(n²). Later chapters cover the specific enumeration techniques (nested loops, bitmasks, permutations) and how to est7 min read
03Chapter 3: Pairs and Tuples with Nested LoopsMany brute-force solutions come down to one job: look at every pair, or every triple, of items and check each one against a condition. Nested loops are the simplest way to do that. They are also easy to get subtly wrong. A loop bound that is off by one can skip candidates, check an item against itse6 min read
04Chapter 4: Getting It Right Before Getting It FastThis chapter assumes you can write Python functions and loops, know what a list and a dictionary are, and can read simple Big-O claims. It also builds on the previous chapter's nested-loop two-sum solution. That solution is the running example here.6 min read
05Chapter 5: Will It Run in Time? Estimating Brute-Force CostThis chapter assumes you can write loops and recursion in Python, know basic Big-O notation, and have already defined a search space and written the nested-loop two-sum solution from earlier chapters. The aim here is a habit you can apply before writing any code. Multiply a few numbers, compare the 7 min read
06Chapter 6: Trying Every Subset with BitmasksMany problems ask you to choose some items from a collection: a group of numbers that hits a target sum, a set of tasks that fits a time budget, a team that covers every required skill. The brute-force answer to all of them is the same. You try every possible selection and keep the ones that work. T6 min read
07Chapter 7: Trying Every Ordering with PermutationsSome problems ask you to choose an ordering of items rather than a group of them. Examples include the order in which to visit cities, the sequence in which to run jobs, and the arrangement of people at a table. Each candidate solution in these problems is a permutation, which is one specific orderi7 min read
08Chapter 8: When Brute Force Is Good Enough to ShipEarlier chapters treated brute force as a starting point: a correct baseline you write first and then replace. Sometimes the replacement never needs to happen. This chapter covers how to decide, with evidence, that the brute-force version is the version you ship, and how to ship it without leaving a6 min read
09Chapter 9: Using Brute Force to Test Faster CodeA brute-force solution is slow, but you can trust it. An optimized solution is fast, but its correctness is harder to see. Stress testing combines the two. You run both on thousands of small random inputs and compare their answers. Any disagreement points to a concrete input where at least one of th7 min read
10Chapter 10: Finding the Wasted WorkA working brute-force solution tells you exactly what work the computer does. To make it faster, read that work closely and find the parts that repeat, recompute, or could never matter. This chapter teaches how to diagnose that waste. The next chapter covers the standard fixes in full, so the fixes 6 min read
11Chapter 11: From Brute Force to an Efficient AlgorithmThis chapter assumes you can write Python functions and recursion, use lists and dictionaries, and read Big-O notation. It also assumes you have a working brute-force solution and have already found where it repeats work, as covered in the previous chapter. Here you turn that diagnosis into a faster6 min read
12Chapter 12: Cutting the Search Short: Pruning and BacktrackingThis chapter assumes you can write recursive functions in Python and read Big-O notation. It also assumes you have seen the bitmask subset enumeration and the permutation-based tour search from earlier chapters. Those solutions visit every candidate, and the goal here is to visit fewer candidates wh6 min read
13Chapter 13: Explaining Your Approach in Reviews and InterviewsEarlier chapters showed how to build a brute-force solution, check that it is correct, estimate its cost, and turn it into something faster. This chapter covers how to explain that process to other people. In a technical interview, the interviewer judges your reasoning as much as your final code. In7 min read