Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 02 · DSA · Choosing the attack · about 17 min to read

Play it as a journeyTutor comes with a plan

Algorithm Design Patterns

Algorithm Design Patterns
Algorithm Design Patterns · Open board

A catalog of five moves, a search tree with most of its branches crossed out before they’re walked, and a guide for reading a new problem’s shape. This lesson is about picking the right move on the first try, not inventing one.

Before you start. You’ve already picked up five tools in this track: arrays, hash maps, trees, graphs, and the trick of a problem asking a smaller copy of itself from Recursion & Dynamic Programming. This lesson is not a sixth tool. It is how you choose between the five you already have, in the first thirty seconds of reading a new problem.

Lesson 14 of 96 in DSA

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 1945: the mathematician who wrote down the plan for having a plan
  • The first move: try everything
  • Split it, solve the pieces, put them back
  • The trap that passes every test you tried
  • The same small question, asked again and again
  • Build one piece at a time, and undo the moment it can’t work
  • Reading the shape, not the wording

Terms it explains: brute force, divide & conquer, greedy, dynamic programming, backtracking, Divide & conquer's, Master theorem, Greedy's proof, Dynamic programming's, The decision guide, all, independent, binary search, two-pointer / sliding window, hashing, balanced BST / heap, heap / priority queue, the meta-method, constraint satisfaction, exchange argument, pruning.

Lab

Grabbing the biggest coin that fits gives the fewest coins with 1, 5, 10 and 25. Does it with any coins?

Pick 1, 3, 4 under The coins, set The amount to make to 6, and watch Coins greedy wasted.

Open The greedy bet

Review DSA