Top 5 Dynamic Programming Patterns for Coding Interviews - For Beginners

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ธ.ค. 2024

ความคิดเห็น • 131

  • @NeetCode
    @NeetCode  2 ปีที่แล้ว +29

    🚀 neetcode.io/ - A better way to prepare for Coding Interviews

  • @tabeebyeamin9986
    @tabeebyeamin9986 3 ปีที่แล้ว +119

    These are good and makes me realize what a great CS curriculum I had that covered all 5 of these lol. I would also study
    6. DFS + memoization (Longest Increasing Path in a Matrix, Path Sum III)
    7. Backtracking + memoization (Regex/Wildcard, Partition to K Equal Sum Subsets)
    8. State Machine (Best Time to Buy & Sell Stock variations)

    • @dj1984x
      @dj1984x ปีที่แล้ว

      are dfs + memoization & backtracking + memoization the same? at least in neetcode's videos, he uses dfs algo for any backtracking problem

    • @alexruan5639
      @alexruan5639 ปีที่แล้ว +3

      ​@@dj1984x DFS is not just backtracking, but backtracking is always DFS.

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

      what are state machine problems and how are they different from any other dp problem can you explain the fundamentals briefly

  • @fightmeonclubpenguin7748
    @fightmeonclubpenguin7748 3 ปีที่แล้ว +62

    This channel is such a great find. I just wish there were more videos haha

  • @davidespinosa1910
    @davidespinosa1910 2 ปีที่แล้ว +42

    DP = recursion + memoization. Then, if you want to memoize using an array instead of a hash map, you can optimize that after. So it's no harder than recursion. But DP often uses a variable number of subproblems, while more straightforward recursions use only one or two subproblems.

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

      The issue is that recursion usually results in exceeding time limit or memory complexity. It's almost as if leetcode expects a bottom up solution. Recursion+memoization works for the simpler problems, but definitely not for problem like 0/1 knapsack

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

      @@_PranavDesai Recursion + memoization works for *all* dynamic programming problems. Look for a leetcode post by chrisTris on 0/1 knapsack and dynamic programming.

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

      Tabulation is also DP and it is not recursive at all

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

      @@wojak6793 Please re-read my comment, thanks.

  • @miettoisdev
    @miettoisdev 2 ปีที่แล้ว +3

    some real quality content here.
    interview material is usually bloated with edgy-cleverish stuff, not structured according to problem's domain of knowledge and not prioritized correctly.
    you, sir, have managed to sort all that out.
    thank 🤜🤛

  • @jinny5025
    @jinny5025 3 ปีที่แล้ว +51

    I'm not confident with dp problems. But this spreadsheet is awesome!! Thank you as always. And congrats you've gained 10k subscribers so far :) You deserve more.

    • @TokyoWasTaken
      @TokyoWasTaken 2 ปีที่แล้ว +2

      damn so he got 200k within year

    • @deathbombs
      @deathbombs 2 ปีที่แล้ว +1

      damnnn 250k now

    • @liz.1328
      @liz.1328 ปีที่แล้ว +1

      516k now

    • @johnnycochicken
      @johnnycochicken ปีที่แล้ว

      another 30k in a month dayum@@liz.1328

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

      @@liz.1328 700k+ now

  • @benjaminkeene5444
    @benjaminkeene5444 2 ปีที่แล้ว +3

    Love the videos. SMALL EDIT: For the “Unbounded Knapsack”, we do not need 2D array. We only need to know MIN(coinsUsed) at each position. Since we can use any coin at each position, we do not need to track type of coins used.

    • @buddyreg234
      @buddyreg234 ปีที่แล้ว

      The feeling that the athor somehow bullshittin us huh ? 😀

  • @karthik829
    @karthik829 3 ปีที่แล้ว +93

    Your videos are really helpful. Just a suggestion, it would be really nice if you could create a video on when we should do backtracking vs dynamic programming. As some seems to fall on both with different runtime and people use different solutions

    • @wongwong7479
      @wongwong7479 2 ปีที่แล้ว +2

      actually, i think both backtracking and dp is bruteforce which try all combination, but if one can build an optimal structure and a DAG , then definitely we should use dp to reduce from exponential time (backtracking/dfs)

    • @AdilProgramming
      @AdilProgramming 2 ปีที่แล้ว +2

      We use dp when their are overlapping sub-problems, here in this problem their is not any sub-problem(part of problem we have already solved)

  • @ranitchatterjee5552
    @ranitchatterjee5552 2 ปีที่แล้ว +5

    I want to thank Neetcode. The videos were great resource to learn coding and crack tech interviews. I'm very thankful to this channel. Hope your channel grows more and more. ❤️

  • @rajeev_nair
    @rajeev_nair 2 ปีที่แล้ว +4

    I don't think 0/1 in 0/1 Knapsack refer to finite/infinite number of the item - its more about if the item put in the knapsack can be fractional or not. 0/1 means either it exists in the knapsack or it does not - in fractional knapsack, you can pick fraction of some item as well -- which would be represented as .someDecimalValue, not 0/1.

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

      Yes correct, this falls in the category of unbounded knapsack where you are not confined to use the element only once.

  • @alexeysubbota
    @alexeysubbota 2 ปีที่แล้ว

    Guy, you really helped me a lot! After watching Climbing Stairs video I did solve Maximum Alternating Subsequence Sum problem not only using DP but using bottom up approach!

  • @venkatasriharsha4227
    @venkatasriharsha4227 3 ปีที่แล้ว +6

    The best Python Leetcode problem solver. Love u brother ❤️

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

    This style of videos is very informative. It helps to structure and categorize the information related to DP problems and allows to come to the solution faster.

  • @varunrajput8083
    @varunrajput8083 3 ปีที่แล้ว +9

    This is perfect. Thank you.
    Can you please make similar lists for other topics as well? That will be extremely helpful because while solving the problem it's good to have an idea about general approach you'll be following..

  • @susmi51910
    @susmi51910 3 ปีที่แล้ว +4

    This is truly life saving! Please make more of this type of videos for other topics.

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

    Thank you @Neetcode, you are changing people's lives

  • @max3446
    @max3446 3 ปีที่แล้ว +2

    Easily the best LC channel, thank you :)

  • @imj3nny
    @imj3nny 3 ปีที่แล้ว +5

    Thank you! This is so helpful! I look forward to more of this type pf high level overview :)

  • @janailtongoncalvesdesouza4160
    @janailtongoncalvesdesouza4160 ปีที่แล้ว

    The way you explain CS is awesome, bro! Keep doing the good job!

  • @TerryFrenchy
    @TerryFrenchy 3 ปีที่แล้ว

    Thanks!

    • @NeetCode
      @NeetCode  3 ปีที่แล้ว +1

      Thank you so much, I really appreciate it! 😊

  • @DaniyaalKhan2000
    @DaniyaalKhan2000 3 ปีที่แล้ว +30

    Are you spying on me? This is literally what I was searching for! xD

  • @eddiej204
    @eddiej204 2 ปีที่แล้ว +1

    The best Leetcode channel ever

  • @piyushaggarwal5984
    @piyushaggarwal5984 3 ปีที่แล้ว +7

    Could you please add the 'Matrix Chain Multiplication' category to this sheet?

  • @calvin_713
    @calvin_713 3 หลายเดือนก่อน +1

    The palindrome checking method so helpful!

  • @AnkitYadav-tf1ww
    @AnkitYadav-tf1ww 2 ปีที่แล้ว

    Very Important for understanding core concepts of dynamic programming.

  • @akhilbaktha5609
    @akhilbaktha5609 3 ปีที่แล้ว +5

    After i suggested neetcode to my friend’s
    My friends: should we bow ?
    Me: Yeah, he’s a king.
    Really love the content, keep going 🔥

  • @shresthgupta6875
    @shresthgupta6875 3 ปีที่แล้ว +1

    Thanks for this spreadsheet.

  • @another14edits74
    @another14edits74 2 ปีที่แล้ว +1

    Can you please make videos on fundamental DP questions (such as the ones you listed in this video) and solve them with multiple solutions describing how you build intuition to build the Brute Force way and optimized it in Top-Bottom/Bottom-Up fashion and finally optimized it with constant space.
    I understand you have explained the approaches in a your videos but can you go in a bit more depth as to how you came up with the Brute Force approach and how you thought that I can optimize it in this way.
    Your videos have been of great help, Thank you.

  • @homi.mp3
    @homi.mp3 3 ปีที่แล้ว +3

    Brilliant explanation, your videos are extremely helpful, thank you for doing all the good work :)

  • @deathbombs
    @deathbombs 2 ปีที่แล้ว

    I've been doing DP for a while so not exactly a beginner, but this is still helpful way to see things

  • @dinhnhobao
    @dinhnhobao 3 ปีที่แล้ว +1

    Great stuff! I have learned a lot from your videos. Please do more of these!

  • @panggrayta
    @panggrayta 2 ปีที่แล้ว

    very clear explanation. good job NeetCode. keep up to date your videos . thanks

  • @whileminseok5110
    @whileminseok5110 3 ปีที่แล้ว +1

    this is so AWESOME!!! thanks for sharing your knowledge :)

  • @subhendurana6457
    @subhendurana6457 2 ปีที่แล้ว

    You are just saviour in my battle-hour!

  • @anujonthemove
    @anujonthemove 2 ปีที่แล้ว +1

    From your Dynamic Programming Patterns sheet, I think Fibonacci Number is kind of Linear DP problem whereas House Robber is more of a Decision Making kind of problem so they should not be falling in the same bucket in case you are categorizing them. Any thoughts?

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

    I think this is really good, though I think we should motivate recursion way more. The grid is fine, but it makes more sense doing that

  • @arnabganguly4962
    @arnabganguly4962 2 ปีที่แล้ว

    Thanks for sharing this approach.

  • @yoyo8293
    @yoyo8293 3 ปีที่แล้ว +2

    I think Longest Increasing Subsequences (LIS) type problems deserve its own category ... Also Maximum Sum Subarray (Kadanes Algo)

    • @tabeebyeamin9986
      @tabeebyeamin9986 3 ปีที่แล้ว +1

      Yeah LIS is pretty big, you have problems like Russian Doll Envelopes & Box Stacking.

  • @kartikhakim4674
    @kartikhakim4674 3 ปีที่แล้ว +1

    Please make and share more videos / spreadsheets like this
    They are really helpful for practice 🙏

  • @d4c98
    @d4c98 2 ปีที่แล้ว

    Finally I finish all the exercises listed in the dp spreadsheet. It has been a lot of help, thank u. wish there are more summary videos like this.

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

    This is probably a long shot but can someone explain how the palindrome solutions are DP? Ive seen the individual problem solutions and they all use the expand from center trick which isn't really memoization thus not really DP(at least how I understand it). On LC, I see solutions of more standard DP approaches that use a 2d array to memoize a string from any 2 start&end points.

  • @algorithmo134
    @algorithmo134 3 ปีที่แล้ว +1

    Looking forward for this

  • @YasirYSR
    @YasirYSR 3 ปีที่แล้ว

    amazing, please keep doing this wonderful work.

  • @anishdeshmukh4690
    @anishdeshmukh4690 3 ปีที่แล้ว +1

    Thanks a lot! You're the best

  • @camiiii272
    @camiiii272 3 ปีที่แล้ว +8

    Just what I was looking for, ty! Just a thought maybe you could extend this to other types of leetcode problems?

    • @NeetCode
      @NeetCode  3 ปีที่แล้ว +3

      Good idea, I definitely will try to work on that!

  • @marioa.castresana6946
    @marioa.castresana6946 2 ปีที่แล้ว

    Awesome video! thank you so much

  • @river.
    @river. ปีที่แล้ว

    you are the best teacher

  • @victormacgrath
    @victormacgrath 2 ปีที่แล้ว

    Really helpful, thank you very much

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

    What's the whiteboarding software? Do you just use a mouse or some sort of pen tablet?

  • @mahmudurrahman1170
    @mahmudurrahman1170 3 ปีที่แล้ว +1

    U are just awesome. thanks a lot

  • @JulianBoilen
    @JulianBoilen 2 ปีที่แล้ว +3

    Do you think it okay to solve DP problems with recursion with memoization? It's often much easier for me to conceptualize the recursive implementation than the iterative one.
    Theoretically it should be the same, but with the use of the call stack.

  • @JTNewby
    @JTNewby 2 ปีที่แล้ว

    You're my hero.

  • @dongni1106
    @dongni1106 2 ปีที่แล้ว

    very good video! thanks so much.

  • @chiraagpala3243
    @chiraagpala3243 3 ปีที่แล้ว +1

    What does for beginners mean? Are there more patterns?

  • @elleech6885
    @elleech6885 3 ปีที่แล้ว

    man i just so love you!!

  • @huangshufen2211
    @huangshufen2211 2 ปีที่แล้ว

    what is the device / software thatdraws on the screen? very interesting

  • @Lamya1111
    @Lamya1111 2 ปีที่แล้ว

    Ace video, mate.

  • @dandyyu0220
    @dandyyu0220 2 ปีที่แล้ว

    I'm just wondering what your adivce would be on how much and what algorithms in terms of coding I should know if I wanna apply for Amazon data scientist role? Thank you!

  • @tawakulislamia9637
    @tawakulislamia9637 3 ปีที่แล้ว

    You got the subscriber💕💕

  • @VivekMishrathetraveller
    @VivekMishrathetraveller 3 ปีที่แล้ว +1

    Can you make a video on Critical connections?

  • @hoyinli7462
    @hoyinli7462 3 ปีที่แล้ว

    thx for your work!

  • @dhruvsakariya3129
    @dhruvsakariya3129 ปีที่แล้ว

    Thank you neetcode

  • @annabellesun4719
    @annabellesun4719 2 ปีที่แล้ว

    you are the god !! thank you

  • @ChiaDai
    @ChiaDai 2 ปีที่แล้ว

    Curious what device and software you use to present like this.

  • @avetiqasatryan1540
    @avetiqasatryan1540 2 ปีที่แล้ว

    why you don't use Binet equation for fibonacci ?

  • @director8656
    @director8656 3 ปีที่แล้ว +1

    Great Video!!!!, are you a faang employee??

  • @ChocolateMilkCultLeader
    @ChocolateMilkCultLeader 2 ปีที่แล้ว

    Fantastic video

  • @mithun532
    @mithun532 3 ปีที่แล้ว

    Thanks a lot ! But after seeing this video i was trying to solve the 1/0 knapsack problem type - equal partition based on tabular method rather than your solution video of the same. Unfortunately I am not able to solve the same can you please create video how tabular method works for the same question ?

  • @netraamrale3850
    @netraamrale3850 2 ปีที่แล้ว

    Thanks alot . Too good....!!!

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

    I am not unable to convert memoisation to dp how to do it ?

  • @Cld136
    @Cld136 3 ปีที่แล้ว

    Could you please do a video on "Longest Palindromic Subsequence"?

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

    very clear

  • @AK09037
    @AK09037 3 ปีที่แล้ว

    Omg ily so much. I think you are missing Matrix Chain Multiplication pattern and DP on trees. But still ILY!!

  • @angelosguan6782
    @angelosguan6782 ปีที่แล้ว

    Another category that might be helpful here is probably matrix/maze problems

  • @hannahruan2764
    @hannahruan2764 3 ปีที่แล้ว

    how to get the spreedsheet

  • @whonayem01
    @whonayem01 2 ปีที่แล้ว

    Thanks. You just made it clear. fear---;

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

    You're one the rare examples of someone with an American accent who pronounces "new" like "nyoo" instead of "noo"

  • @MotoDumpling
    @MotoDumpling ปีที่แล้ว

    Love it~

  • @aniruddhac99
    @aniruddhac99 3 ปีที่แล้ว +1

    Low-key thanks.

  • @yilmazbingol4838
    @yilmazbingol4838 3 ปีที่แล้ว +1

    Mr. Neet Code. I wanna make a request for 935. Knight Dialer if you struggle to choose a question. it is asked by Facebook and there is no explanation on youtube.

  • @subha1818
    @subha1818 3 ปีที่แล้ว

    Is this the same guy who posts daily dose of internet?

  • @Su_Has
    @Su_Has 2 ปีที่แล้ว

    Where is the speadsheet?

    • @NeetCode
      @NeetCode  2 ปีที่แล้ว

      Did you check the description?

    • @Su_Has
      @Su_Has 2 ปีที่แล้ว

      @@NeetCode oops thanks

  • @adesuryaramadhan7565
    @adesuryaramadhan7565 3 ปีที่แล้ว

    can i get the spreedsheet?

    • @NeetCode
      @NeetCode  3 ปีที่แล้ว

      Link should be in the description (let me know if its not working)

  • @billyfung
    @billyfung 2 ปีที่แล้ว

    Amazing

  • @Grimreap191
    @Grimreap191 3 ปีที่แล้ว

    KING

  • @shivambaghel9668
    @shivambaghel9668 2 ปีที่แล้ว

    why you don't put this video a the first place in this dp series

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

    I would definitely become a patron but currently I am struggling financially. If I get a job this year would make a generous donation.

  • @ericc8097
    @ericc8097 2 ปีที่แล้ว

    right

  • @ayush7518
    @ayush7518 2 ปีที่แล้ว

    Can u please reduce the number of adds it's too much irritating

  • @exploringnaturalbeauty2102
    @exploringnaturalbeauty2102 3 ปีที่แล้ว

    5:25

  • @luxurylifestyle3804
    @luxurylifestyle3804 3 ปีที่แล้ว

    Binary tree cameras leetcode

  • @Bromon655
    @Bromon655 ปีที่แล้ว +1

    I feel so stupid watching these videos.

  • @chilly2171
    @chilly2171 3 ปีที่แล้ว +1

    You seem to make things harder with explanation and graphs. You should explain with a datastructure, like in an array or hashmap, etc or say a for-loop etc for context to make it easier to understand.

  • @20x20
    @20x20 2 ปีที่แล้ว

    the "right?" is pretty distracting

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

    n33tc0de, I love u bruh

  • @Pogibakayo
    @Pogibakayo 3 ปีที่แล้ว +2

    Thanks!

    • @NeetCode
      @NeetCode  3 ปีที่แล้ว

      Thank you so much Alex!!!

  • @HusainDalal
    @HusainDalal 2 ปีที่แล้ว

    Thanks!

  • @bifidoc
    @bifidoc 2 ปีที่แล้ว

    Thanks!

  • @angrychick7543
    @angrychick7543 2 ปีที่แล้ว

    Thanks!

  • @Sword-32-21
    @Sword-32-21 2 ปีที่แล้ว

    Thanks!