Dynamic programming (DP) is often considered the most dreaded topic in coding interviews. It has a reputation for being abstract and contradictory, but it doesn’t have to be.
We have just published a comprehensive dynamic programming course freecodecamp.org YouTube channel that uses a visual-first approach to learning these complex algorithms.
Developed by Sheldon, a former Google engineer with over 10 years of experience, this course focuses on helping you develop visual intuition for optimization. Instead of asking you to memorize hundreds of individual problems, Sheldon teaches you to recognize the basic patterns that connect them.
The course breaks down dynamic programming into six basic paradigms, explaining the logic and code (using Python) for each:
Permanent Transfer: Learn the basics with problems like climbing stairs and house robbers, where the state depends on a fixed number of previous states.
Grid Pattern: Learn how to create tables to solve navigation challenges.
Two sequences: Discover how to compare strings and sequences using 2D tables, covering classics like long-joint acquisition and modification distances.
Interval DP: Dealing with problems involving finding optimal structures within intervals, such as the longest palindromic congruence.
Non-Permanent Transfer: Consider complex transitions where the state depends on a variable number of previous states, which is illustrated by the long-time increasing inverse problem.
Knapsack-like problems: Master problems include specific sum building or replenishment capabilities, such as partition equivalent subset sums and coin flips.
View the full course freecodecamp.org YouTube channel (2 hour clock)