Dynamic Programming - Learn to Solve Algorithmic Problems & Coding Challenges

Поділитися
Вставка
  • Опубліковано 10 лип 2024
  • 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: / @coderbytedevelopers
    🔗 Improve your coding and interview skills: coderbyte.com/member?promo=ja... (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: www.freecodecamp.org
    Read hundreds of articles on programming: freecodecamp.org/news

КОМЕНТАРІ • 3,9 тис.

  • @rudycenaronaldo5476
    @rudycenaronaldo5476 3 роки тому +6710

    No. I don't want to be a software engineer at Google. Please leave me alone algoexpert I just wanna learn dynamic programming.

    • @donsurlylyte
      @donsurlylyte 3 роки тому +592

      resistance is futile, you will be absorbed, prepare for the interview

    • @MZ-uv3sr
      @MZ-uv3sr 3 роки тому +55

      @@donsurlylyte haha...me neither. I should apply just for grins, to see what it's like.

    • @blossomwithcurls
      @blossomwithcurls 3 роки тому +116

      Literally every video I click!!

    • @rahul_bali
      @rahul_bali 3 роки тому +11

      Yeah, man. Whats with the grin .. Little too happy..

    • @phat80
      @phat80 3 роки тому +101

      in fact, this is the most annoying ad ever! This plump woman with a nasty voice will come to me in my nightmares.

  • @sleros7773
    @sleros7773 3 роки тому +806

    The first thing I'm gonna do when I get a job is to donate to FCC. I've learned so much from their content on UA-cam and tutorials on their website.

  • @danieladetayo3711
    @danieladetayo3711 11 місяців тому +137

    I am 45 mins in, but I had to stop to drop this comment. This is hands down one of the best tutorials I've ever seen.
    Alvin is a true teacher. I am blown away by his style. I have taken paid courses on this topic, but this is the first time I am understanding what this is about. I can't wait to finish this tutorial.
    I am going to go for all your courses.

  • @pelvispresley22
    @pelvispresley22 Рік тому +14

    This is the slickest way I've ever seen not only Dynamic Programming, but also recursion presented. His slides/animations are just perfect for guiding every single step your brain needs to go through along the way, and he handles all kinds of gotchas and keeps you from getting stuck. I'm already going from "holy cow how am I going to even approach these problems" to "ok this is starting to get intuitive with this workflow" just an hour in. Literally better than any professor's teaching style than I remember from my college CS program. The effort put into this video is insane!
    I have a feeling this video just covers some of the basics-intermediate problem types, but I bet this will be a great stepping stone to tackling the harder DP problems.

  • @davidchen1900
    @davidchen1900 3 роки тому +5523

    This guy is going to be invited to my wedding.

  • @souravas
    @souravas 3 роки тому +2282

    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...

  • @RandomShowerThoughts
    @RandomShowerThoughts Рік тому +98

    still can't believe how good this course is, like legitimately taught me more on algorithms, recursion, and dp than anything I've ever seen

    • @YS-cc1nk
      @YS-cc1nk 4 місяці тому

      You mean so?

  • @slpn1
    @slpn1 2 роки тому +18

    I've been coding since 1998 and have watched countless tutorials on countless topics. This guy is definitely one of the best teachers I've ever come across.

  • @Malediction99
    @Malediction99 2 роки тому +164

    This guy has the most relaxing voice of any lecturer I've heard.

    • @feafel
      @feafel 2 роки тому

      So true!

  • @rajurawat2763
    @rajurawat2763 3 роки тому +356

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

    • @TheQuancy
      @TheQuancy 2 роки тому +6

      Alvin is amazing. He currently works for google right now

    • @calculator4482
      @calculator4482 2 роки тому +3

      That's because he is crazy

    • @takirr6818
      @takirr6818 2 роки тому

      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

  • @ragzzytv
    @ragzzytv Рік тому +142

    my man Alvin! I'm a Senior Developer but it was always a grind to brush up DSA topics when I'm in the job hunt. Your videos helped me quantify it a lot. I just watch your DSA videos in 1.5x half a day before an interview and that is all I need. Very well put both for beginners and for folks like me who need a quick run-through. This is the kind of stuff internet is made for. Appreciate the great work. keep it up!

  • @kanuos
    @kanuos 2 роки тому +42

    This is definitely the best course on Dynamic Programming I have ever done. Notice, not the _best free_ course, the _best_ course, period.

    • @SaiyaraLBS
      @SaiyaraLBS 24 дні тому +1

      a note: go donate on their website, it's tax free (As they are non profit), they get the full amount and you pay no taxes. UA-cam charges taxes to both the channel and the donator.

  • @SuperAshleyriot
    @SuperAshleyriot 3 роки тому +246

    This is the first standing ovation I've given to a UA-cam video.

  • @calvint678
    @calvint678 3 роки тому +330

    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!!!

    • @CoderbyteDevelopers
      @CoderbyteDevelopers 3 роки тому +25

      we meet again! thanks for watching -Alvin

    • @calvint678
      @calvint678 3 роки тому +4

      @@CoderbyteDevelopers ooooo you just got a new sub.

    • @sonukumarkeshri4696
      @sonukumarkeshri4696 3 роки тому +1

      Hey join this guys
      www.scaler.com/event/coding-interviews-dynamic-programming?rcy=1&rce=f6cd5eeb1984

    • @WillsonMock
      @WillsonMock 3 роки тому +3

      @B Q is there a video link for his data structures and programming videos?

    • @ShekharNeupane
      @ShekharNeupane 3 роки тому +2

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

  • @nastrimarcello
    @nastrimarcello Рік тому +10

    I'm not one to watch any 5 hour video but this one really hooked me to go all the way.
    Explaining hard things in a simple and engaging way is hard and you delivered it perfectly.

  • @bernhardbaumgartner4702
    @bernhardbaumgartner4702 2 роки тому +87

    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 🙇

  • @lelouchnorequiem1357
    @lelouchnorequiem1357 3 роки тому +701

    Quality content from Quality Teachers,that too for free!!❤️❤️

    • @sonukumarkeshri4696
      @sonukumarkeshri4696 3 роки тому +1

      Hey join this guys
      www.scaler.com/event/coding-interviews-dynamic-programming?rcy=1&rce=f6cd5eeb1984

    • @brileyakang4590
      @brileyakang4590 3 роки тому +3

      No, Not for Free. You Paid with Attention Dollars, :)

    • @brileyakang4590
      @brileyakang4590 3 роки тому +4

      @Harshil Pandey "Attention Dollars" is dollar you pay when you "Pay Attention" 😏😋

    • @neerajkale
      @neerajkale 3 роки тому +5

      Someone tell this to WhiteHatJr ppl

    • @user-vi3pi9rf7w
      @user-vi3pi9rf7w 3 роки тому +5

      @@neerajkale I can't still fathom that scam is still running

  • @autismo1969
    @autismo1969 2 роки тому +541

    This man literally taught me more dynamic programming than paid university courses

    • @khanaleena1161
      @khanaleena1161 2 роки тому +3

      Kis language ka hai, c ya c++ ,ya java

    • @milkmeapollo9048
      @milkmeapollo9048 2 роки тому +6

      This is the problem with America lol

    • @exploringnaturalbeauty2102
      @exploringnaturalbeauty2102 2 роки тому +4

      @@milkmeapollo9048 entire world dude , I aint american but my country has the same problem , universities are the biggest scams ever.

    • @zackjandali
      @zackjandali 2 роки тому +23

      @@user-wl5tv4jl7v it's not a scam but they are definitely over priced. I think of college as my source for what I need to know, and the internet (mainly youtube) as my source of knowing those things. Without college/universities, it's hard to know what you need to know. It would take a lot of asking questions and bothering people who didn't sign up to be questioned... lol

    • @juanandrescastillofuenmayo6619
      @juanandrescastillofuenmayo6619 2 роки тому +7

      I usually can't symphatize with ppl who say this, but yeah, DP is probably the biggest thing the internet has been able to taught me better than a price-near-the-seven-hundred-thousand-colombian-pesos uni course.

  • @cocolasticot9027
    @cocolasticot9027 2 роки тому +18

    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 !

  • @sachinsachin-ms9mr
    @sachinsachin-ms9mr 11 місяців тому +42

    I'm here after watching graph algo. I am a data engineer and I always struggled to understand the space and time complexity, this animation is all I ever wanted. This is by far the best video I watched on dynamic programming. Moreover, Alvin has that charm to keep me captivated for long hours without loosing focus. Keep up the great work man!

    • @billcosta
      @billcosta 10 місяців тому +9

      i think it would've been better if you supported his main channel

    • @ankitjaiswal272
      @ankitjaiswal272 8 місяців тому +2

      @@billcosta can someone please suggest the main channel of the tutor....
      His teaching style looks best to me.
      Thanks

    • @ranawareviraj
      @ranawareviraj 8 місяців тому

      www.youtube.com/@AlvintheProgrammer@@ankitjaiswal272

    • @oii0712
      @oii0712 7 місяців тому +1

      Give this to Alvin

  • @carocardozo1507
    @carocardozo1507 3 роки тому +246

    I finished it and I feel like my head is burning from excitement and curiosity for practicing. It was amazing.
    Thank you so much for this course

    • @Daniel_WR_Hart
      @Daniel_WR_Hart 2 роки тому +4

      Dynamic programming truly is crystal meth

    • @khz2172
      @khz2172 2 роки тому +1

      how good are you in DP now?

    • @veipuniilana1842
      @veipuniilana1842 2 роки тому

      which pograming language are you uisng for coding?
      If you are using java can i ask you some questions?

    • @sebryxs
      @sebryxs 2 роки тому +4

      @@khz2172 I don't think he's that good, the course only teaches the basics and some simple problems. If you want to become good at DP I think you should practice with some DP problems (from codeforces, for example)

    • @utopiabinary8258
      @utopiabinary8258 2 роки тому

      all 5 hours?

  • @hello777l
    @hello777l 2 роки тому +22

    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!

  • @akenteva
    @akenteva Рік тому +2

    I watched this in just 2 sittings. The explanations are so clear and well laid out. A lot of repeats of course, but that's kind of a good thing in this case because it helps to get used to the topic. Alvin is an amazing teacher.

  • @tmanley1985
    @tmanley1985 Рік тому +3

    This is the best dynamic programming content I've ever seen. What I found particularly helpful is being able to understand and view recursive problems as a tree. Because of course trees are recursive data structures. When you have a tree from the outset, as long as you understand general principles of DFS and BFS, a lot of solutions become obvious. What this guy does is show a way to make the implicit, explicit. It's that step that is usually the most difficult because sometimes you're just given a number and asked to solve the problem. Once you understand that problem with that starting value represents a tree of decisions, it allows you to visualize it in such a way that the solution becomes evident. Great job.

  • @krisnrg
    @krisnrg 2 роки тому +254

    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

    • @shivamdhir640
      @shivamdhir640 2 роки тому +1

      does he teach backtracking in the video ? Haven't started watching it.

    • @exploringnaturalbeauty2102
      @exploringnaturalbeauty2102 2 роки тому +1

      @@shivamdhir640 not specifically but discussed in some questions

  • @devandeva4374
    @devandeva4374 2 роки тому +10

    I love the way he teaches and his love for coding can be seen in his face, whenever he smiles after hitting the code. Thanks man

  • @andrewwestley537
    @andrewwestley537 2 роки тому +1

    Alvin I have been studying for months and i have taken my time through this video - single handedly drove home soo many concepts and helped me get a solid understanding and an easy translation into Python code. Thank you!

  • @rosem5062
    @rosem5062 Рік тому

    Two hours into the video and I was able to write my own little recursive function without looking at any notes! I never understood it before! The visualization at the beginning of the video was key for me. Thank you for breaking it down so thoroughly.

  • @LeetCodeSimplified
    @LeetCodeSimplified 3 роки тому +19

    Had I searched for "dynamic programming" two days earlier, this video wouldn't even have been uploaded to youtube. The timing couldn't be better!

  • @rahultech77
    @rahultech77 3 роки тому +41

    Wow. Dynamic programming looked so daunting on the outside. In a matter of 2 days, you changed my mindset about it for good :)
    Now it seems easy and doable. Many thanks!

  • @zjucypher
    @zjucypher 2 роки тому +8

    This is THE BEST algorithm course I have ever seen on youtube. Wish there are more videos like this!

  • @kirillzlobin7135
    @kirillzlobin7135 7 місяців тому +2

    YOu should be given an award as the best tutor on Dynamic Programming concepts in the history!!! You approach is so detailed and step-by-step. You found the best formula on how to teach these complex things. Thank you very much for your job!!!

  • @WillsonMock
    @WillsonMock 3 роки тому +74

    This is one of the most clear and succinct explanations on the memoization and tabulation techniques for dynamic programming!

    • @veipuniilana1842
      @veipuniilana1842 2 роки тому

      which pograming language are you uisng for coding?
      If you are using java can i ask you some questions?

  • @warrentait4610
    @warrentait4610 3 роки тому +61

    I can't believe you made this with over 2,000 slides. You're a hero.

    • @lilpapa7598
      @lilpapa7598 3 роки тому +2

      What did he use to create those slides ?

    • @CST1992
      @CST1992 2 роки тому

      Yeah, that coordination is spot-on.

  • @indrekk5
    @indrekk5 Рік тому +1

    In the last example. Spread operator pushes elements to call stack. Maximum call stack exception can be avoided by replacing this line:
    table[i + word.length].push(...newCombinations);
    with:
    table[i + word.length] = [...table[i + word.length], ...newCombinations];
    Great course!

  • @a2xd94
    @a2xd94 Рік тому +45

    Brilliant video! The entire community of learners owes you a coffee for teaching us this excellent approach to solving the infamous dynamic programming problems. Other videos and books do not go into this well-defined mindset and step-by-step strategy that you need to develop, in order to understand and ultimately solve these problems from a *pragmatic* approach (which is what ultimately aces technical interviews). Keep up the great work, Alvin!

  • @cooladi002
    @cooladi002 2 роки тому +853

    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.

    • @LogansDarling
      @LogansDarling 2 роки тому +39

      did u spend money making this comment

    • @TomasLKarlik
      @TomasLKarlik 2 роки тому +49

      @@LogansDarling while I'd argue there are probably better, more direct ways to support a creator, what makes it so weird to you? People have been spending cumulative billions of dollars over the past years just for having their message read on stream or purely for support. It's basically a pay-what-you-want scheme.
      If you really feel like shaming other people's spending, I suggest you may start with people buying shiny rocks to put on rings with otherwise zero value and ethically questionable production.

    • @LogansDarling
      @LogansDarling 2 роки тому +48

      ​@@TomasLKarlik while I'd argue that shaming someone for how they choose to support someone is lame, financially or otherwise, what makes you think that's what I was doing? People have been being confused by the billions of new features YT has put on their platform over the past years just because they're not used to it. It's basically a guess-what-this-symbol-means scheme.
      If you really feel like assuming the motives of peoples' questions, I suggest you may start with people sarcastically belittling people to cancel anyone who doesn't follow their exact position with otherwise zero value and ethically questionable means.
      jokes aside i understand how that could be misconstrued as an insult but i was genuinely wanting to kno cuz it could have been like idk
      - Spending money on a specific comment.
      - Spending money on a channel.
      - Spending money on YT.
      - Spending money outside of the platform and the YTer giving them the badge.
      - No money even being spent and me just thinking something is a currency symbol.
      - It could be _anything_ considering how stupid I am, so I have no clue.
      although if u kno that its for a specific comment then ig u answered me so thx
      (I do think that it's stupid, but that's more on YT's part than the commenter's part. Seems like a stupid feature to add on the platform, but that hasn't stopped YT before so oh well. ¯\_(ツ)_/¯)

    • @cooladi002
      @cooladi002 2 роки тому +6

      @@TomasLKarlik could you shed more light on the more direct ways to support a creator ?

    • @ghaznavipc
      @ghaznavipc 2 роки тому +3

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

  • @isfland
    @isfland 3 роки тому +68

    It's amazing to realize that grid traveler problem sounds like a completely different problem to fibonacci, but it's solved with the same pattern. Just wow.

    • @WillCrawford0
      @WillCrawford0 2 роки тому +1

      @black c yeah, C(m + n, n).

    • @veipuniilana1842
      @veipuniilana1842 2 роки тому

      which pograming language are you uisng for coding?
      If you are using java can i ask you some questions?

    • @KartikayKaul
      @KartikayKaul Місяць тому

      You will find in theory of computation that the problems are divided into sets of similar problems ie we can reduce any problem to any other problem to solve and if we can solve just one problem in that set in an more efficient time complexity then we can solve other problems in that set the same way

  • @hindigente
    @hindigente 2 роки тому +4

    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.

  • @miljanmatovic880
    @miljanmatovic880 2 роки тому +1

    Love the methodical approach and no steps being jumped over, great job!

  • @terrymiller111
    @terrymiller111 2 роки тому +4

    You are a coding instructing master. There are millions of people who code, but only a few coding instructing masters. Great stuff. You deserved every one of those subs and likes.

  • @gopishivakrishna9707
    @gopishivakrishna9707 2 роки тому +10

    After finishing this video in 2 full days, I am able to come up with an approach now, and write solutions. No matter how much efforts I made to learn dp, I was no where close to coming up with a neat approach. With these concepts and some more practice on the DP problems, I can sure be good as a hell pro problem solver in a month.

  • @SamYuXiaofei
    @SamYuXiaofei Рік тому +3

    This is an amazing and helpful tutorial!
    For GridTraveler program, we can solve it analytically. Assume a grid with size m*n , then to go from the top left to the bottom right, the total number of step moving right has to be (n-1), and the total number of step moving bottom has to be (m-1), the overall total number of step has to be n-1+m-1 = m+n-2.
    Any particular path is an arrangement of steps of these two types of directions. Therefore, it is equivalent to say that if we have total m-1+n-2=m+n-2, then count the number of ways we can pick m-1. So the analytical solution is (m+n-2)!/[(m-1)!(n-1)!] , where ! means factorial

  • @donatellodonini3147
    @donatellodonini3147 3 роки тому +19

    Thanks for this tutorial: with your lectures I improved an algorithm that calculates any of level the Pascal's triangle, it was really satisfying to see the big improvement with a very few lines of code

  • @johnvanschultz2297
    @johnvanschultz2297 2 роки тому +15

    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.

  • @MeinDeutschkurs
    @MeinDeutschkurs 2 роки тому +1

    Alvin, thank you so much for uploading this video. I got into programming as some kind of a hobby. Your video not only taught me two very important principles, but also brought me understanding for terms that my math teacher-25 years ago-was not able to explain. Thank you so much!!! 🤗

  • @ehabahmedyassen
    @ehabahmedyassen Рік тому

    I really like how Alvin's explanation progresses gradually and at the end of the tutorial i feel much more comfortable with the Ideas and I can see how problems are relative to each others. Thank you Alvin so much, you are our HERO!

  • @jasonford1
    @jasonford1 3 роки тому +14

    It is always a treat to find content perfectly paired to one's journey in programming. For me, this content is exactly what I need. Thank you Alvin and thank you FCC for distributing! Unbelievable that this is free.

  • @paulchoudhury2573
    @paulchoudhury2573 3 роки тому +32

    This the best and most informative explanation of DP I've seen in 25 years! Great job and I hopefully some day you'll be compensated well for your outstanding teaching ability.

  • @Error-rp4dk
    @Error-rp4dk Рік тому

    This is my first comment on youtube but i can't thank you enough for this course it literally saved my life and my algorithms and data structures exam.
    My professor was completely useless, he just copy-pasted notes from a mit course by Erkik Demaine (while obviously not having the same teaching nor programming skills lol ) and arranged our exam as a coding interview (two problems in 1 hour and a half). University gave us little to no experience in programming (we just had two programming courses in computer engineering) and after graduations i felt like my skills were very weak and coding was my biggest fear. This course gave me confidence and made me realize once and for all that coding is 80% thinking and 20% writing actual code. Now i can't say i'm a pro but i feel a lot better and i passed the exam with 30/30 so a complete success! Unfortunately i'm still studying so i don't have a job, but i will donate once i have a stable income! For everyone worrying about failure, trust yourself, you're smart enough, i know you can do it! Just don't panic and break the problem into simple fool-proof steps. I promise it gets easier and even fun, don't give up!

  • @RandomShowerThoughts
    @RandomShowerThoughts Рік тому +1

    Might be the best video on not just Dynamic Programming, but also for Recursion that I've ever seen

  • @giulio4686
    @giulio4686 3 роки тому +27

    This is a great short course with a great teacher!! 😉😉😉😙 The classes I attended about dynamic programming in my university are not even comparable to this. This is much more understandable, well presented and makes you want to keep learning the topic.

  • @yangtairan
    @yangtairan 3 роки тому +5

    This is probably THE best DP tutorial on the web! Kudos to FCC, Coderbyte, and Alvin.

  • @MANISHKUMAR-vt3lp
    @MANISHKUMAR-vt3lp 2 роки тому +30

    00:00 Intro to dynamic programming
    3:22 Understanding the need for Dynamic programming
    10:48 Understanding time complexity and space complexity
    22:27 Back to the need for dynamic programming with an example
    23:31 Dynamic programming - how it reduces the time complexity
    25:56 Implementation of dynamic programming using memoization
    38:38 More problem

  • @DemX_HaX
    @DemX_HaX 4 місяці тому +1

    one of the worst things about learning new DSA concepts is the jump in logic/thinking thats made where it doesn't make sense until you've done a million examples because people don't really explain their thought process and the intuition behind it much.
    this has none of those issues. this is probably the best DSA video i think i ever seen. amazing work, thank you. 🎉

  • @joshuabenson2568
    @joshuabenson2568 2 роки тому +134

    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.

    • @puppergump4117
      @puppergump4117 2 роки тому +1

      I don't think it's about slow or quick, it's just that schools don't teach us how to think. They just cram crap down our throats and expect use to puke up rainbows.

    • @ingaprobatorem5839
      @ingaprobatorem5839 2 роки тому +1

      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).

    • @ingaprobatorem5839
      @ingaprobatorem5839 2 роки тому

      o(1) for storage.

  • @bhargavpandya9189
    @bhargavpandya9189 2 роки тому +23

    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!!

    • @ytg6663
      @ytg6663 2 роки тому

      Link

    • @Fredchin18
      @Fredchin18 2 роки тому

      @@ytg6663 ua-cam.com/video/tWVWeAqZ0WU/v-deo.html

  • @singhohi
    @singhohi 8 місяців тому +1

    I've always been afraid of DP because of how counter-intuitive it can be sometimes. I also struggled with memoization and tabulation options. Thanks a ton for this video. Helped me a lot.

  • @sbahuddin
    @sbahuddin 5 місяців тому

    Alvin has made dynamic programming so much easier and quite fun to understand and code in. This video also strengthened my divide-and-conquer concepts, what a cherry on the top!
    Recursion tree explanation, animations, multiple examples and the way he helped to visualize how things actually work are just too good.
    My man also took things gradually, step by step and covered a lot without letting us get tired of it

  • @kingkaixyz
    @kingkaixyz 2 роки тому +207

    The visualization and break down of these concepts are so well done. Kudos!

  • @hadeeltantawy3244
    @hadeeltantawy3244 2 роки тому +2

    That was definitely awesome! They guy just takes you from point A to point B in the smoothest way, no leaps. Thank you for this amazing tutorial, it's definitely worth the 5 hours!

  • @ryani897
    @ryani897 2 роки тому

    This is a fantastic, helpful video. I'm brushing up on some concepts I learned in university in preparation for interviews, and frankly you explain things better than most of my professors did. Thank you!

  • @joudawad1042
    @joudawad1042 Рік тому +1

    Thank you man so much for all the amazing content in here, after years and years of struggling I am finally able to understand these complicated topics with your help, it is not just about the dynamic programming but it is more about understanding how to analyze the recursive problems and how to think out of the box you are just amazing !!

  • @ssandeep79
    @ssandeep79 3 роки тому +14

    Definitely, one of the best courses to start with DP. Just started with the tabulation approach and, decided to attempt it after watching the initial explanation. But decided to follow a different approach as below:
    def fibDPTabulation(position):
    if position

    • @vekyll
      @vekyll 2 роки тому +1

      Yeah, I wondered that too, why he's doing forward tabulation instead of backward one. But for the later problems with strings, it really makes much more sense to think forward, so he just wanted to establish consistent practice.

  • @franciszekwieczorek5292
    @franciszekwieczorek5292 3 роки тому +13

    Hey, this is truly one of the best tutorials I've seen so far and very appreciated. Many thanks for your time!

  • @parikshitdas3984
    @parikshitdas3984 Рік тому +4

    For the howSum code, if you're having trouble spreading the array (in case you're using something other than JS). Try solving it with booleans, kinda like the canSum problem, and then if it returns true, then just add the num in a global array/ ArrayList/ Vector.

    • @louiecastle462
      @louiecastle462 Рік тому

      Do you even need to spread the array? It seems suboptimal.
      You should be able to push onto the array in O(1) time in most languages.

  • @supriyabansal7036
    @supriyabansal7036 Рік тому +3

    Thanks for the great content.
    In gridTraveler problem, base condition could be that if either of rows or columns is 1 , we can return 1
    So, if(m == 1 || n == 1) return 1;
    And i think we could just check m and n interchangeably :
    if ((m + "-" + n) in memory) return memory[m + "-" + n];
    if ((n + "-" + m) in memory) return memory[n + "-" + m];
    As number of ways to travel a grid for (2,3) will be same as number of ways in case of (3,2)

  • @Serit76
    @Serit76 2 роки тому +3

    this is a godlike Tutorial. I recommend to everyone watching to pause after the problem is introduced and think of a way to solve it and then watch the explanation. Adds some more depth to this amazing work!

  • @blossomwithcurls
    @blossomwithcurls 3 роки тому +228

    You literally explained the course in a simple and legit way!! So, DP can be this easy??? 🏃🏾‍♀️🏃🏾‍♀️ me heading to leetcode to solve the hard DP problems!

  • @mohammedkaifmirza7585
    @mohammedkaifmirza7585 Рік тому

    Hands down, it is impossible to describe in words the way this man teach the recursion problem in first quarter.

  • @diegorocha2186
    @diegorocha2186 Рік тому +7

    In the example of canConstruct 2:24:00 you can use the method `startsWith` since you're just interested in knowing if the target starts with the word, so you don't need to traverse the entire string finding the index! Amazing course btw I really appreciated!

    • @repentandbelieveinJesusChrist3
      @repentandbelieveinJesusChrist3 Рік тому

      Repent to Jesus Christ “We demolish arguments and every pretension that sets itself up against the knowledge of God, and we take captive every thought to make it obedient to Christ.”
      ‭‭2 Corinthians‬ ‭10:5‬ ‭NIV‬‬

    • @ItsAllAFacade
      @ItsAllAFacade 9 місяців тому

      @@repentandbelieveinJesusChrist3 Annoying-ass bot.

    • @ItsAllAFacade
      @ItsAllAFacade 9 місяців тому

      Also, I was thinking, can't you also use a trie to pre-compute data within the word bank, so you can efficiently access it during the recursion?

  • @preetijindal5030
    @preetijindal5030 3 роки тому +8

    I am writing this review by just viewing the content for 30 mins. I loved it. I was bit reluctant to start as Dynamic Programming is very difficult and yet very important at the same time. This has given me a boost of confidence as i was able to code the same concept in Java. Thank you so much. And Happy Coding everyone.
    No matter how difficult it seems, we would go through it Together. :)

  • @jleal666
    @jleal666 2 роки тому +105

    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

    • @siidsharma5349
      @siidsharma5349 2 роки тому +3

      you're right, so that solution give O((m+n)/2)

    • @kumaranp8764
      @kumaranp8764 2 роки тому +6

      @John Leal i was looking for this in the comments
      memoized base case after this optimization would look like
      if (m, n) in memo:
      return memo[(m, n)]
      elif (n, m) in memo:
      return memo[(n, m)]

    • @Mihir.Hundiwala
      @Mihir.Hundiwala 2 роки тому +8

      Finally i found the comment i was looking for thanks.

    • @J3rs3yM1k3
      @J3rs3yM1k3 2 роки тому +15

      Exactly. He even mentions this while describing the solution, but didn't implement it.

    • @Mark33090
      @Mark33090 2 роки тому +6

      Was wondering that too, I tried it out... Passing a grid of 500,500, I measured the time it took for it to run... 230ms without and 125ms with the sorting.

  • @_kingston
    @_kingston Рік тому

    Found this while cramming for an exam. Helped me to understand the material better than months of classes and multiple homework assignments

  • @bishbashboshjt
    @bishbashboshjt 2 роки тому +3

    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)

  • @kamalkamalazmi2226
    @kamalkamalazmi2226 3 роки тому +16

    Definitely one of the best instructors I've ever known. Thank you sir

  • @SebinMatthew
    @SebinMatthew 3 роки тому +39

    No book can explain DP this well and believe me I have tried!

    • @lighttheoryllc4337
      @lighttheoryllc4337 3 роки тому

      Assalamualaikum brothers and sis, I am seeking Software Engineers, whom can code in Tensor flow and RNN Time series. I am paying.. I am based in USA.. Please check out lighttheory.page/ or email us at info@LightTheory.tech SALAM

  • @AnOmegastick
    @AnOmegastick 9 місяців тому +1

    For tabular bestSum, you don't have to compare the length of the arrays. If you're iterating through and filling in the future values as you go, you can just skip if the value you're filling isn't null.

  • @goblinmoblin4869
    @goblinmoblin4869 Рік тому

    Alvin, this course is EXTREMELY well done. I thoroughly enjoyed working through it. It taught me the importance of diagramming a problem visually before attacking it.

  • @hackytech7494
    @hackytech7494 3 роки тому +5

    This is one of the best explanation for Dynamic programming on entire UA-cam. I have never seen such an clean and Fantastic explanation. Thanks alot

  • @neerajkulkarni6506
    @neerajkulkarni6506 3 роки тому +13

    Amazing! The visualization as a tree really helps to understand DP!

  • @harpercfc_
    @harpercfc_ 2 роки тому

    Finished nearly a quarter of this tutorial. It is really awesome.
    Thank you so muuuuuch Alvin.

  • @jvixtor
    @jvixtor Рік тому +2

    Thanks for the fabulous course 👏🙏One modification that I think the video needs is that for the grid travel algo with memoization, the space complexity is O(m*n) and not O(m+n) [1:04:15]. The stack of course uses O(m+n) space but the 'memo' object grows to store m * n key/val pairs. So the overall space complexity would be O(m*n).

  • @synhegola
    @synhegola 3 роки тому +18

    Great so far. If the first half hour is an indicator of the rest, I already learnt more in that half hour than in the past 10 years... Great job

  • @venkateshnayak5096
    @venkateshnayak5096 3 роки тому +65

    I actually felt bad when this course ended. Felt as if a part of my life's story just rested.

    • @LUKFUNTV
      @LUKFUNTV 2 роки тому +3

      😅😄
      What a nice line there👍👍

    • @veipuniilana1842
      @veipuniilana1842 2 роки тому

      which pograming language are you uisng for coding?
      If you are using java can i ask you some questions?

  • @manojb7961
    @manojb7961 Рік тому +1

    The tutorial on DP can't get any better! Quality content. Best out there. Thank you very much!

  • @alicecgong
    @alicecgong Рік тому

    I am using this to refresh my muscles for DP because I haven't interviewed for a while, and doing a speed run of this video has actually worked quite well, so good job! Although my memory is coming back lol - there is an even more optimal way to solve the Fibonacci problem where the space complexity is O(1): you can simply store the 2 previous value only as you go along, instead of storing the entire history.

  • @mounika2973
    @mounika2973 3 роки тому +15

    Before I thought I would never be able to solve problems using dynamic programming , but now I have a lot more confidence. Thank you for this amazing video😁

    • @sonukumarkeshri4696
      @sonukumarkeshri4696 3 роки тому +1

      Hey join this for more stuffs
      www.scaler.com/event/coding-interviews-dynamic-programming?rcy=1&rce=f6cd5eeb1984

  • @remivantrijp8968
    @remivantrijp8968 3 роки тому +13

    Congratulations on making such a clear tutorial! I will definitely point my students to this if they need to get up to speed about dynamic programming

  • @thienlu7011
    @thienlu7011 Рік тому +1

    The way he explained it can't be better! Many thanks.

  • @chukwuemekainya3043
    @chukwuemekainya3043 Рік тому +2

    Very lovely tutorial. I finally feel confident about solving recursion and DP problems.
    I have a observation: At 2:32:27, why is the target.indexOf(word) === 0 not factored in, in the calculation for time complexity. Even though we are comparing against 0, target.indexOf(word) will first search through the word, which is (O(m)) before comparing against 0. This should leave us with an overall time complexity of O(n ^ m * m ^ 2).

  • @AHMEDADEL-qx2ip
    @AHMEDADEL-qx2ip 2 роки тому +14

    After graduating with a CS degree and working for 2 years, I can finally explain to someone what DP is!
    Phenomenal and unbelievable course. Can't thank you enough for this high-quality content.

    • @ytg6663
      @ytg6663 2 роки тому

      R u doing job ?

  • @romanzelinskyi7566
    @romanzelinskyi7566 3 роки тому +11

    The best Dynamic Programing course I've had so far, thanks a lot for the best teacher.

    • @veipuniilana1842
      @veipuniilana1842 2 роки тому

      which pograming language are you uisng for coding?
      If you are using java can i ask you some questions?

  • @SquittenPlease
    @SquittenPlease Рік тому

    Actually the best video I've found. You're explainations are easy to follow and clear. Even if the concept it's tricker, I didn't find myself getting frustrated. Thank you for this!!

  • @r0f115L4m
    @r0f115L4m 2 роки тому

    Alvin, this is absolutely incredible. Highest quality content on the web for dynamic programming problems.

  • @pablogarin
    @pablogarin 3 роки тому +11

    47:00 last node to the right should be 2,0... still a base case, so no difference overall, but it's best to clarify to prevent people of confusion and frustration...

  • @neilbruce6091
    @neilbruce6091 2 роки тому +8

    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!

    • @shambhav9534
      @shambhav9534 Рік тому

      Were you new to C++ or even programming in general, back then? Writing it in code is the easiest part, and on top of that, when you have a direct translation possible, it's even easier.

    • @lKOKOLIZO
      @lKOKOLIZO Рік тому

      could you share your code please?

  • @sehajsingla3029
    @sehajsingla3029 Місяць тому

    Hands down. I am not a very good student of programming however, the way this person teaches is impeccable. I am solving questions side by side and I am getting all the answers right within the first go. Thank you so much for your efforts and you should really teach me everything because I am UNSTOPPABLEEE.

  • @bobp040653
    @bobp040653 10 місяців тому

    Recursive programs are in use here and there, but I was a software engineer from 1975 to 2005 working for Pratt & Whitney Aircraft, a Route 128 CAD/CAM company, Apollo Computer (Sun Micro competitor), and Knight Securities (Nasdaq Market Maker start up). In all that time, I never wrote any recursive code, or changed any recursive code. When I retired i wrote a Scrabble playing program, to see what recursive programming was like.

  • @erwinmulder1338
    @erwinmulder1338 3 роки тому +29

    In the GridTraveler I would have used (1,x) and (y,1) as base cases, as there's only one way to go down a straight line.

    • @exismys
      @exismys 2 роки тому +1

      yeah more optimization

    • @Iongjump
      @Iongjump 2 роки тому

      Same here

    • @tanieadas
      @tanieadas 2 роки тому +1

      Anyways every unique pair is getting calculated only once.

    • @davidrebatto6713
      @davidrebatto6713 2 роки тому +1

      I had the same idea, but as @Taniea said, you still end up computing all possible pairs.
      You don't even save the lookup time, as the lookup occurs before the 'if' condition.