Dynamic programming is a powerful technique that has been a cornerstone in the world of algorithms and computer science. It's a method that breaks down problems into smaller, more manageable sub-problems, solving each one only once and storing their solutions in case they're needed again. This approach is particularly useful for optimization problems, where you seek the best solution amongst a set of feasible solutions.

We just posted a course on the freeCodeCamp.org YouTube channel that will teach you Dynamic Programming techniques with Java.

Alvin Zablan created this course. It provides a deep dive into dynamic programming and teaches a lot of key algorithms.

What is Dynamic Programming?

Dynamic programming is a method for solving complex problems by breaking them down into simpler sub-problems. It is a way to solve problems by using solutions to smaller instances of the same problem.

The key idea behind dynamic programming is quite simple. In general, to solve a problem, you solve some sub-problems. Dynamic programming is used when the sub-problems are not independent, i.e., when sub-problems share sub-sub-problems. In this context, divide and conquer algorithms do more work than necessary, repeatedly solving the common sub-sub-problems. Dynamic programming algorithms remember past results and use them to find new results.

When is Dynamic Programming Used?

Dynamic programming is often used in optimization problems where we have to find the best solution among a set of feasible solutions. It's particularly useful when a problem has overlapping sub-problems. Instead of computing solutions to these sub-problems repeatedly, dynamic programming suggests solving each of these sub-problems just once, saving their solutions, and returning the saved solution when the same sub-problem is encountered again.

Dynamic Programming in Coding Interviews

Dynamic programming is a favorite topic in coding interviews. Interviewers love to test the understanding, analytical skills, and problem-solving abilities of candidates using dynamic programming problems. It's not just about knowing the technique but also about understanding when and how to use it. Mastering dynamic programming can give you a significant edge in coding interviews.

Course Breakdown

Here are the sections covered in the course:

  1. fib: Dive into the Fibonacci sequence, a classic example to kickstart your dynamic programming journey.
  2. tribonacci: Explore the tribonacci sequence, a variation of the Fibonacci sequence.
  3. sum possible: Learn to determine if a sum is possible with given numbers.
  4. min change: Find out the minimum change required from a set of denominations.
  5. count paths: Count the number of paths in a grid.
  6. max path sum: Calculate the maximum path sum in a grid.
  7. non adjacent sum: Find the maximum sum without adding adjacent numbers.
  8. summing squares: Understand the concept of summing squares in dynamic programming.
  9. counting change: Learn different ways to count change using given denominations.

Whether you're a beginner looking to understand the basics of dynamic programming or an advanced coder aiming to brush up your skills, this course has something for everyone.

You can watch the full course on the freeCodeCamp.org YouTube channel (3-hour watch).