DecodingIntuition
DecodingIntuition
  • 2
  • 230 424
Dynamic Programming: 3 consistent steps from recursive to iterative
If you can do it recursively, you can do it iteratively. I'll show you 3 steps to convert any recursive dynamic programming solution into an iterative one: defining bounds, managing dependencies, and replacing recursive calls with values!
If you haven't watched my first video on dynamic programming, go watch that first: th-cam.com/video/gK8KmTDtX8E/w-d-xo.html.
มุมมอง: 18 678

วีดีโอ

Dynamic Programming isn't too hard. You just don't know what it is.
มุมมอง 212K4 หลายเดือนก่อน
#dynamicprogramming #leetcode

ความคิดเห็น

  • @ciarlok7778
    @ciarlok7778 4 วันที่ผ่านมา

    how are u moving around the text so fast 9:48

  • @muzamil705
    @muzamil705 7 วันที่ผ่านมา

    I felt the goosebumps I feel when I solve math questions during school. Mannn its crazy and you sparked the new way to look at problems. I cant explain in words how much satisfied I feel right now. God bless all the fortune to you.

  • @massaynus
    @massaynus 8 วันที่ผ่านมา

    0:44 totally agree.. DP is just misunderstood XD

  • @Alpheamus
    @Alpheamus 9 วันที่ผ่านมา

    I'm a pretty smart guy and I've been self teaching myself multiple coding languages for years now. This video made me feel retarded. Can someone explain to me wtf a Cache Complexity is? The phrasing in some parts of the video has me lost entirely, even if the actual solution makes sense.

    • @Alpheamus
      @Alpheamus 9 วันที่ผ่านมา

      Don't get me wrong though. I love the video! Amazing quality and is very informative.

  • @gunjan_ks
    @gunjan_ks 18 วันที่ผ่านมา

    tried breaking down the question into smaller parts, didnt work ( different questions btw) , after 1hr 37 mins i got exhausted and looked for the solution, do you think this is bad practice ?

  • @lethebuster
    @lethebuster 19 วันที่ผ่านมา

    2:16 Dude turned up about dp lol

  • @Zooiest
    @Zooiest 21 วันที่ผ่านมา

    14:56 moistcr1tikal

  • @frytura
    @frytura 23 วันที่ผ่านมา

    oh, so THATS how you do problem solving! i aways do this on my head, turns out i WAS doing something wrong.

  • @ROMERO2280
    @ROMERO2280 25 วันที่ผ่านมา

    I want to create a simple 2D Game Engine with Integrated Development Environment (IDE) in C++ But to develop this Big Project, it needs strong Math and that's where I would start learning to be a software engineer. Linear Algebra - makes it easier to understand 3D Graphics. Discrete Math - makes it easier to understand algorithm development. I'd start with Math.

  • @GosuNoKami
    @GosuNoKami 26 วันที่ผ่านมา

    17:50 isn’t it (n+1)*(amount+1) since both include 0 in counting?

  • @GosuNoKami
    @GosuNoKami 26 วันที่ผ่านมา

    Based channel name

  • @Nunolin
    @Nunolin 27 วันที่ผ่านมา

    okay but what if im not using python and dont have the magic @cache to save my results?

  • @jarail
    @jarail 29 วันที่ผ่านมา

    Really nice video! I agree with your approach to solving these. You break things down really well and do a good job explaining your thought. Thanks!

  • @serdna8378
    @serdna8378 29 วันที่ผ่านมา

    Legit the chadest video I've seen on this topic.

  • @unkn0wnrge189
    @unkn0wnrge189 หลายเดือนก่อน

    What is funny is that if you understand soo much complexity eventually you making a refactor making o(n ^ 2) to O(n) willl not be valuabled as the professional who do O(n ^ 2) but he does it faster.

  • @MadDeuceJuice
    @MadDeuceJuice หลายเดือนก่อน

    The dirties, most filthy approach in all of programming…

  • @neoanderson1865
    @neoanderson1865 หลายเดือนก่อน

    this video confused me even more. i hope one day it makes sense to me

  • @anmax
    @anmax หลายเดือนก่อน

    Dude, you changed my programming life

  • @riya-qz9uk
    @riya-qz9uk หลายเดือนก่อน

    why is cached complexity O(n) for catalan?

  • @ohmpatel3286
    @ohmpatel3286 หลายเดือนก่อน

    best explanation of DP i've ever seen, love the idea of not relying on tables

  • @gr.4380
    @gr.4380 หลายเดือนก่อน

    Please return this is the best series on programming problem solving I've seen 😢

  • @user-ee1fn4vt8b
    @user-ee1fn4vt8b หลายเดือนก่อน

    witchcraft

  • @riddhivekariya9086
    @riddhivekariya9086 หลายเดือนก่อน

    We'd worship you , if you keep uploading man

  • @riddhivekariya9086
    @riddhivekariya9086 หลายเดือนก่อน

    Keep uploading please

  • @avid4839
    @avid4839 หลายเดือนก่อน

    Wish you finished the thought you had at 15:52. What were you going to do to fix your naive recursion?

  • @WilliamWang-m4i
    @WilliamWang-m4i หลายเดือนก่อน

    You are DP GOD🙏 It's all math down the root. So clear. I'll rewatch this multiple times. THIS is TRUE problem solving.

  • @_derpyvik_8273
    @_derpyvik_8273 หลายเดือนก่อน

    Commenting for the algorithm, thanks man

  • @WilliamWang-m4i
    @WilliamWang-m4i หลายเดือนก่อน

    I see wisdom and clarity. Thank you.

  • @mxpph
    @mxpph หลายเดือนก่อน

    this is the greatest educational video ive ever seen on this entire platform

  • @heinrichpreussen
    @heinrichpreussen หลายเดือนก่อน

    holy fuck this video is awesome

  • @bigboland6160
    @bigboland6160 หลายเดือนก่อน

    honestly completely ignoring what this video is about and the dynamic programming part, you should make a shorter video just going over how you analyze and write out the different parts to figure out exactly what your trying to solve. ima start doing this for every leetcode problem, and honestly any recruiter would probably be shocked and impressed if you did all this during an interview

  • @dIancaster
    @dIancaster หลายเดือนก่อน

    You are a goddamn machine. I'm in awe. The way you knew it would pass even before running it? I'm so deeply impressed.

  • @pedro_soares_bhz
    @pedro_soares_bhz หลายเดือนก่อน

    Damn, that is beautiful reasoning right there!

  • @psibarpsi
    @psibarpsi หลายเดือนก่อน

    the right image is related to tabulation. what's the left image related to?

  • @lucascamelo3079
    @lucascamelo3079 หลายเดือนก่อน

    Repeat with me: recursion can't be faster than procedural

  • @sgalloway111
    @sgalloway111 หลายเดือนก่อน

    Thank you

  • @rubyciide5542
    @rubyciide5542 หลายเดือนก่อน

    I hate cache and that's all the reason i need to skip learning dp

  • @nolan_meyer
    @nolan_meyer หลายเดือนก่อน

    20:17 re: Richard Bellman “I spent the Fall quarter (of 1950) at RAND. My first task was to find a name for multistage decision processes. “An interesting question is, ‘Where did the name, dynamic programming, come from?’ The 1950s were not good years for mathematical research. We had a very inter- esting gentleman in Washington named Wilson. He was Secretary of Defense, and he actually had a pathological fear and hatred of the word, research. I’m not using the term lightly; I’m using it precisely. His face would suffuse, he would turn red, and he would get violent if people used the term, research, in his presence. You can imagine how he felt, then, about the term, mathematical. The RAND Cor- poration was employed by the Air Force, and the Air Force had Wilson as its boss, essentially. Hence, I felt I had to do something to shield Wilson and the Air Force from the fact that I was really doing mathematics inside the RAND Cor- poration. What title, what name, could I choose? In the first place I was interested in planning, in decision making, in thinking. But planning, is not a good word for various rea- sons. I decided therefore to use the word, ‘programming.’ I wanted to get across the idea that this was dynamic, this was multistage, this was time-varying-I thought, let’s kill two birds with one stone. Let’s take a word that has an absolutely precise meaning, namely dynamic, in the clas- sical physical sense. It also has a very interesting property as an adjective, and that is it’s impossible to use the word, dynamic, in a pejorative sense. Try thinking of some com- bination that will possibly give it a pejorative meaning. It’s impossible. Thus, I thought dynamic programming was a good name. It was something not even a Congressman could object to. So I used it as an umbrella for my activi- ties” www.researchgate.net/publication/220243993_Richard_Bellman_on_the_Birth_of_Dynamic_Programming

  • @ru2979
    @ru2979 2 หลายเดือนก่อน

    Bro are u a GM on CF or wot , u explaining concepts like that 😮 reminds me of my DSA trainer online 😮😮😢

  • @Harishiv18
    @Harishiv18 2 หลายเดือนก่อน

    0:33 can’t believe we are still taking shots at the verse pc build guide

  • @andrewsoares8941
    @andrewsoares8941 2 หลายเดือนก่อน

    You are fucking amazing guy, wtf. Thanks a lot

  • @rcj1337
    @rcj1337 2 หลายเดือนก่อน

    2:27 ”different view of not only DP, but also problem solving - as a hole” - I get it now, DP and holes go toghether, makes sense

    • @dev__noob_9299
      @dev__noob_9299 หลายเดือนก่อน

      I see what you did there ... 🧐

  • @mingoc1785
    @mingoc1785 2 หลายเดือนก่อน

    Is your problem solving adapted from how to solve it? That book’s is next in my reading list

  • @amazingbanter
    @amazingbanter 2 หลายเดือนก่อน

    The side effects tidbit was probably the most important part for me. The subproblems must be pure.

  • @isaacalinda
    @isaacalinda 2 หลายเดือนก่อน

    “HAANNKKK DONT ABBREVIATE DYMAMIC PROGRAMMING ON THE THUMBNAIL”

  • @davidpark2116
    @davidpark2116 2 หลายเดือนก่อน

    great explanation! this made things so clear. how do you get those vim motions in leetcode?

  • @Darth_Insidious
    @Darth_Insidious 2 หลายเดือนก่อน

    At it's basic essence, dynamic programming is looking for ways to reuse computational steps for multiple steps/iterations of a problem.

  • @tagberli
    @tagberli 2 หลายเดือนก่อน

    Best explanation on the entire planet, the world needs you, man

  • @OJ000
    @OJ000 2 หลายเดือนก่อน

    This video definitely taught me a lot, but I think you may be wrong in the time analysis for the code you wrote. It doesn't look like your caching the values for each state anywhere so the recursion is still doing many recomputations. Due to this I'd say your code has exponential growth rather than polynomial growth. I tested this out by putting your same code into leet code and got a TLE. I then added a 2d array to act as a cache and was able to submit successfully

    • @DecodingIntuition
      @DecodingIntuition 2 หลายเดือนก่อน

      You might want to check again. @cache is used.

  • @nickolasbrown2260
    @nickolasbrown2260 2 หลายเดือนก่อน

    I agree . Dp is just misunderstood. 😂