Dynamic Programming – Learn to Solve Algorithmic Problems & Coding Challenges

Wordpress sites

Learn how to use Dynamic Programming in this course for beginners. It can help you solve complex programming problems, such as those often seen in programming interview questions about data structures and algorithms.

This course was developed by Alvin Zablan from Coderbyte. Coderbyte is one of the top websites for technical interview prep and coding challenges.

🔗 Check out the Coderbyte channel:
🔗 Improve your coding and interview skills: (NOT an affiliate link)

This course uses images and animations to help you visualize problems and important concepts. After understanding problems conceptually, you will learn how to solve them in JavaScript using Dynamic Programming. Even though JavaScript is used in this course, you will learn concepts and knowledge that you can apply to other programming languages.

⭐️ Course Contents ⭐️
⌨️ (00:00:00) course introduction
⌨️ (00:03:30) fib memoization
⌨️ (00:38:39) gridTraveler memoization
⌨️ (01:04:52) memoization recipe
⌨️ (01:09:56) canSum memoization
⌨️ (01:29:29) howSum memoization
⌨️ (01:52:06) bestSum memoization
⌨️ (02:12:45) canConstruct memoization
⌨️ (02:38:36) countConstruct memoization
⌨️ (02:47:30) allConstruct memoization
⌨️ (03:10:53) fib tabulation
⌨️ (03:22:17) gridTraveler tabulation
⌨️ (03:34:32) tabulation recipe
⌨️ (03:37:59) canSum tabulation
⌨️ (03:53:01) howSum tabulation
⌨️ (04:07:21) bestSum tabulation
⌨️ (04:20:50) canConstruct tabulation
⌨️ (04:38:06) countConstruct tabulation
⌨️ (04:50:23) allConstruct tabulation
⌨️ (05:07:44) closing thoughts

⭐️ Special thanks to our Champion supporters! ⭐️
🏆 Loc Do
🏆 Joseph C
🏆 DeezMaster

Learn to code for free and get a developer job:

Read hundreds of articles on programming:

And subscribe for new videos on technology every day:

47 thoughts on “Dynamic Programming – Learn to Solve Algorithmic Problems & Coding Challenges”

  1. Damn this guy was the instructor for app academy. His explanations actually put me on the track to understanding this crazy world of code. So glad he’s back on the scene!!!

    1. Shekhar Neupane

      @Coderbyte completely off-topic question if you don’t mind: What microphone are you using?

  2. It took me a week to finish this tutorial.
    This tutorial is just pure gold.
    I always found it hard to understand time complexity for recursive solutions. But this video explains it perfectly.
    This is probably the best tutorial on dynamic programming. I can’t believe you’re giving such quality content for free…

    1. 01:04:10 – OBVIOUS MISTAKE??? Did he forgot to calculate space occupided by THE CACHE? Space should be O(n * m), not O(n + m) OMG

    2. Damien Spectre

      what software is he using to design the trees etc? looks handy to convey system design

  3. After getting frustrated from these dynamics programing, after hunting to know the real concepts in books, articles, online paid courses, YouTube videos, finally got this here and that too free. I can’t believe this. He teaches like crazy. Thanks a lot.👍

    1. He’s crazy – 01:04:10 – OBVIOUS MISTAKE – he forgot to calculate space occupided by THE CACHE. Space is O(n * m), not O(n + m) OMG OMG OMG

  4. John Van Schultz

    This is one of the best videos on both recursion and dynamic programming I’ve ever seen. Thank you for making this available and sharing this knowledge with the programming community.

  5. Man, Alvin, I watched your Graph Algorithms course first and I absolutely loved it! I saw people there, recommending this legendary course and I just knew I had to come here! Every single second watching this video was completely worth it!

    There is no way I can praise your explanation enough Alvin! There just is not!

    After this going through this video, I went from literally have no clue whatsoever about what dynamic programming even means, to completely falling in love with this subject. I would surely indulge myself into this subject, and I believe that this video right here is simply the best entry point for any developer out there who is willing to learn this subject.

    Thanks Alvin. I am really very grateful!!

  6. 1:04:12 The number of paths of [2,3] is the same as [3,2], so the function can be optimized a little more by sorting the keys: if m<=n then key = m + ',' + n else key = n+','+m .

    1. The goal was to teach us the ropes, not to make the most efficient code possible. In fact, he specifically mentions that when solving the fib problem with arrays. There’s of course a much simpler way to do it, but he says it’s beyond the point. There are other optimizations that could be done: for instance, in the last problem, if we determine allocation is slow, redundant solutions could be eliminated by encoding the solutions as strings and using them in a map (e.g. map[string] bool = {“a,a,a,a” = true, “aa,aa” = true, “aaa,a” = true, “a,aaa” = true }), that way we don’t need to store similar solutions with all the possible a’s, just the first occurrence. Again, beyond the point.

    2. Or you could write this as key = std::to_string(std::min(m, n)) + “,” + std::to_string(std::max(m, n))

    3. @Kumaran P if (key === (m,n) || key === (n,m)) if(n>m) return(n,m) else return (m,n). I think he purposefully omitted it to decrease complexity.

    4. Ayush Agarwal 4-Year B.Tech. Electronics Engineering

      same I was thinkihng , he mentioned it but did not add it to his code

  7. Phenomenal teacher, I’ve got an hour left and even though I’ve fumbled my way through similar problems I feel I understand everything much better. This is now my go to recommended video for recursion and dynamic coding

  8. This course just proves that when you go through each minute detail of a problem in a calm and precise manner, while also hinting at the obvious even, a student is much more likely to pick up on the subject. Judging by all the other comments, slower people like myself are starting to get the concept. 🤣

    Fantastic coure, thank you very much for uploading this piece.

    1. INGA probatorem

      The author did not include in the compute complexity the access of the memoized data. For the fibonacci, the algorithm can be optimized to o(1) instead of o(n).

  9. This is hands down the best crash course on dynamic programming. After struggling for so many hours on dp, I actually feel that I understand the logic and process for tackling dp problems now. Thank you for this amazing video!

  10. Signed in to give my appreciation for all your hard work, and GREAT work, putting together this series. Easily the best teaching series on the subject I’ve seen. Only a few errors that are easily overlooked. Only issue I had was I was converting the problems into C++, but that’s not a knock on the series, if anything, the fact that I was so easily able to convert your solutions to C++ is indicative of a thorough explanation of the problems rather than just coding examples.

    Thanks! I wish you did more!

  11. Simply THE best dynamic programming course on youtube, wonderfully explained.
    The course made understanding the difficult concepts a breeze.
    Loved the progression of problems, even the harder ones felt easy after understanding the basic strategy and the recipe.
    Thank you freeCodeCamp and Alvin.

    1. Mohammad Ghaznavi

      first time seeing a GOLDEN -COMMON- comment on youtube
      (sorry… I played too much hearthstone recently…)

    2. of cource it is the beas, since for example iterative approach is not shown 😀

    3. Mohammad Ghaznavi

      @Tunde Adegbola It’s probably because he/she donated to freecodecamp via youtube in some way.

  12. smurfandturf

    3:52:52 the space is actually the size of the largest value in the numbers array, (due to growing the array to i + num) which could be way larger than the target value (unless I am misunderstanding and the array becomes sparsely represented for a huge index so not memory hungry)

  13. Bernhard Baumgartner

    I’ve never seen anyone before who was able to better and more clearly explain dynamic programming. The way you’re leading us there step by step and also how the material is presented is outstanding. I’m very impressed Good Sir 🙂 Thank you very, very much 🙇

  14. Praful Parashar

    Great video !!
    Best one out there for DP.
    Personally, I feel better to work through subsets generation or having different combination through memoization technique.
    While for grid problems in DP, tabulation is best to visualise and solve as well.

  15. Although I’m not a programmer by trade, my line of work sometimes demands some rather tricky coding, and I’m sure this intro to dynamic programming will prove to be quite helpful. Can’t thank you enough for making it freely available.

  16. This is a great tutorial for anyone really wanting to learn this well. Very detailed and thorough. If I was new to DP this would be a good pace. It’s a little slow for a refresher, but otherwise fantastic.

  17. Coco L'Asticot

    Learning to code by myself, this course brought me so much.

    I didn’t know anything about dynamic programming, not much about time and space complexity.
    Now I wouldn’t say that i master it of course, but with those great explanations and examples I happened to cruise through all these exercises with ease.

    I am genuinely shocked to see how easy it is for me now, as those problems just seemed impossible before and their solutions looked like witchcraft.

    Thank you so much, this is a wonderful course !

  18. In best sum could be hugely optimized by ordering the numbers array in descending order, thus making the tree branches shorter (substract bigger values from the target, less steps to reach 0).

    *Edit* Alvin mentions that this is an incorrect assumption, but I will stand behind it. Taking the smaller numbers first will dive deep into the tree, whereas big numbers will find or fail sooner and thus result shorter answers faster. In Alvin’s example he will get 1,1,1,1,1,1,1,1; 1,1,1,1,4; 4,1,1,1,1; and so on before finding 4,4. Descending order will only find 5,1,1,1;

    Also if there is a sum with 2 numbers found, there is no point in searching deeper than that in other branches.

  19. Before doing memoization on grid-traveler, the base conditions could use some simplification:
    if(m === 0 || n === 0) return 0;
    if(m === 1 || n === 1) return 1;

    This should greatly cut down the number of recursions even before memoization. I am not sure why only the case of a (1,1) grid is returning 1. It should be any (n,1) or (1,n) provided that n > 0. A single column or single row has only one solution.

Comments are closed.