Dynamic Programming 2D - Full Course - Python

Поділитися
Вставка
  • Опубліковано 17 чер 2024
  • 🚀 neetcode.io/ - A better way to prepare for Coding Interviews
    Checkout my second Channel: @NeetCodeIO
    🥷 Discord: / discord
    🐦 Twitter: / neetcode1
    ⭐ BLIND-75 PLAYLIST: • Two Sum - Leetcode 1 -...
    💡 DYNAMIC PROGRAMMING PLAYLIST: • House Robber - Leetco...
    0:00 - Intro
    1:10 - Unique Paths
    11:48 - Longest Common Subsequence
    30:00 - Best Time to Buy/Sell Stock with Cooldown
    45:01 - Coin Change II
    1:08:12 - Target Sum
    1:20:07 - Interleaving String
    1:39:19 - Longest Increasing Path in a Matrix
    1:55:53 - Distinct Subsequences
    2:07:10 - Edit Distance
    2:27:55- Burst Balloons
    2:49:01 - Regular Expression Matching
    #leetcode #neetcode #python
  • Наука та технологія

КОМЕНТАРІ • 101

  • @learningalgos614
    @learningalgos614 Рік тому +168

    I’m convinced your stuff is better than Algoexpert

    • @awk3340
      @awk3340 Рік тому +11

      bye 110% this guy is awesome

    • @learningalgos614
      @learningalgos614 Рік тому +9

      Why are you guys liking me lmao, like Neetcode instead

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

      to be fair i have algoexpert and that shit is good

    • @Tyler-jd3ex
      @Tyler-jd3ex Рік тому +4

      I think they are both GREAT. I love Clement so much but Neetcode definitely has way more content for free which I appreciate dearly

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

      without a doubt.

  • @chukwunta
    @chukwunta Рік тому +8

    This is such an amazing resource. Finally I now understand 2D DP better. Thanks so much. I truly appreciate all your effort, you have bee a great asset to my journey through this algo-verse.

  • @kashishsingh5813
    @kashishsingh5813 Рік тому +8

    Ohh Man...you are great
    Finally ....someone making so much comprehensive course on 2d mtrix

  • @dorothychristina2721
    @dorothychristina2721 Рік тому +26

    Hi Bro.Please do a full course on graph problems .It would be really helpful.This video is awesome 👌

  • @sukanyasaha5458
    @sukanyasaha5458 Рік тому +20

    Woow this is gem. Can you please please do a comprehensive video on Graph?

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

    Your explanation is better than anything i have see online

  • @foxh8er
    @foxh8er 4 місяці тому

    A lot of these videos handwave things away, but these are really good solutions. Cheers

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

    This is insane! Thank you so much

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

    Thanks lots for putting together this rich resource.

  • @AryanSingh-zv5ch
    @AryanSingh-zv5ch Рік тому

    Loved it thanks for the amazing explanations❤

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

    literally you are the only one that i can complete his video without being bored

  • @user-od1hv9dv8p
    @user-od1hv9dv8p 4 місяці тому

    As a freshman in CS, dp is such a tall ask for me to overcome. And this series save me... respect for neetcode!

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

    Awesome, thanks!

  • @yuemingpang3161
    @yuemingpang3161 Рік тому +5

    Thank you very nice course on 2D dp! Just a reminder, there is a typo in the disctinct subsequences section:
    dfs(i+i, j) should be dfs(i+1, j)
    Thank you!

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

    Hey, I received an offer from Amazon for SDE 2 role. I have been following you for long time now. You have a fair share in my success. Keep doing the great job.

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

      That's awesome, congratulations on the offer!! And thanks for the kind words :)

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

    If I learn something from this video, I’m definitely signing up for lifetime access

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

    For the first problem, you can think of it as a scenario where you have letters that are r’s and d’s for the directions and the order of these matter. In the example, you would have 6 r’s and 2 d’s. You want to find all the possible orderings of these letters as a string/sequence. You do this by fixing the r’s then d’s (or the other way around). This means you would get (6+2) choose 2 * 6 choose 6. This is the same as 8 choose 2, which is 8*7/2=28. In general, it would be (n + m - 2) choose (n-1). You could also use (m-1) and can find the min of n and m to find out which calculation would be faster.

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

    Man this guy is awesome

  • @madhumithakolkar_
    @madhumithakolkar_ 7 місяців тому

    There's actually a mistake at 2:06:00 for the problem - Distinct Subsequences, great explanation by the way ! While you've mentioned it properly , there's a typo in the code >> cache[(i,j)] = dfs(i+1,j+1)+dfs(i+i,j) This should be dfs(i+1,j) , you have mentioned it as i+i in all the places.

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

    Thank you!

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

    First problem you can use combinatorics - because you know you know you have to go m moves across and n down. But if you want to have any blockers or if you allowed up and down this does not hold

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

    Hi, I like the explanations you give before diving into the coding. Can you please make a video on Leetcode 310 (Minimum height tree) problem. I appreciate your altruism. Thanks

  • @utti_12c
    @utti_12c 2 місяці тому

    Thank you🙏

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

    awesome!!

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

    Thanks man .

  • @pvhung174
    @pvhung174 Рік тому +5

    I want to ask, what is your thought process when youre comming up with the solution?
    I cant seem to figure out what to use when solving the problems.

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

    Hi, can you make a detailed explanation video on leetcode 1770 for the iterative solution please. It gives TLE for the memoization approach. A big thanks for this video

  • @hikmetdemir1032
    @hikmetdemir1032 4 місяці тому

    Could you please make an example training video for backtracking, graphs, tree and sliding window, starting from easy level to difficult level, just like you do for dynamic programming?

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

    Christmas came early!

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

    Hi, please make a lecture on LC 1626. Best Team With No Conflicts! Love your way of teaching!!

  • @podilichaitanyaakhilkumar4911

    Please do more videos on frequently asked questions in Maang interviews on leetcode.

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

    For Distinct Subsequences(2:06:10) use modulo on line 14 like this to get the correct answer when length of s is too long:
    if(s[i] == t[j]):
    cache[(i,j)] = dfs(i + 1, j + 1)%m + dfs(i + 1, j)%m
    here m = int(1e9+7)

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

    nice good neatcode :)

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

    For the first problem, I guess the only optimization (beyond knowing the math eq) would be selecting the smaller of m and n, so that your memory complexity is minimized.

  • @RC-qr8bn
    @RC-qr8bn Рік тому

    Have you thought about adding Swift language solutions on your website?

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

    Hey, could you apply tiered pricing based on where your subscribers live? Some of us in Africa really get hit hard by the exchange rate... Big time.

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

    Thanks!

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

      Thank you so much 🙏🙏🙏

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

    WOOOW!

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

    typo in the problem Distinct subsequences. It should be dfs(i+1,j) instead of dfs(i+i,j) in line 14 and 16

  • @build-your-own-x
    @build-your-own-x Рік тому

    11:50 LCS
    30:00 stock selling
    45:00 coin change

  • @GoogleAccount-ph8mm
    @GoogleAccount-ph8mm Рік тому

    Please make video in dynamic programming in Java

  • @jay-rathod-01
    @jay-rathod-01 Рік тому

    Yeah baby.❤

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

    Dope

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

    awesome

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

    Can you please consider to extend the discount sale upto end of this month.

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

    is 2d array dp and pointer approach the same time complexity?

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

    Best coding channel. End of

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

    Hey could you please make a video on LC problem number 273

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

    godly

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

    thanx man , when will be the system design course coming ?

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

      Hopefully by end of October, but I will try to upload it as I complete each lesson

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

    Explanations are good, but as someone who always wants to try and find out complete solution myself, it does take time for me and it does get a bit demotivating, so my question to you is that, did you figure out solutions to all problems by yourself or you took help or how did you approach these programming questions? Hope to get an answer.

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

      I definitely had to look at the solution a lot when I first started

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

      @@NeetCode Thank you, appreciate your time and response. :)

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

    Edit Distance: What if we have fourth option is exchange two adjacent character?

  • @bonle3771
    @bonle3771 7 місяців тому

    gaw damnn 3 hrs for 2d dp

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

    Hey neetcode please solve the problem no 1478 of leetcode largest continuous subaaray with abs diff les than limit

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

    Shortest Path in Binary Matrix can you please solve this question leetcode 1091

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

    for coin change 2 problem
    dp=[0]*(amount+1)
    dp[0] = 1
    for coin in coins:
    for i in range(1, amount+1):
    if i - coin >=0:
    dp[i] += dp[i-coin]
    return dp[-1]

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

    Superb!

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

    Naisu

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

    I am the winner today

  • @xxrazorxx1073
    @xxrazorxx1073 3 місяці тому

    why did burst ballon become max coins?

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

    32. Longest Valid Parentheses can you solve this please?

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

    LeetCode 638 explanation plz

  • @user-ps1vq2kw8h
    @user-ps1vq2kw8h Рік тому

    Many thanks

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

    You would increase the quality of my life if you made discrete math videos (you know the math needed for CS).
    Stuff like Karatsuba's, Recursion Tree's, Induction Proofs, Asympotic time complexity would really help!

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

      since you are doing not strictly leetcode and all

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

    1:38:00

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

    When is the sale gonna last until?

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

      About 1 more week

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

      @@NeetCode what is difference of the content on your UA-cam channel and your paid subscription on your website?

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

    Could you please publish greedy algorithms full course lecture?

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

    Got TLE for burst balloons

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

      in C++, got TLE while using map for caching. Got accepted by using vector for caching

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

    If you keep all premium content here then what is the use of buying premium. I didnt get. But thanks as it is helpful for people who cant afford like me

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

      These questions are from 150 LC list , even his normal videos feel really premium :D

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

      These solutions are already available for free, I just compiled them into one video

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

      @@NeetCode ohh thanks for your reply☺☺

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

      @@cyberserker yes because of him i am able to solve problems. We all need teachers like him at some point in our life

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

    first!!!! i am the first

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

    this is so god damn complicated wtf

  • @AryanSingh-eq2jv
    @AryanSingh-eq2jv Рік тому

    ```py
    class Solution:
    def longestCommonSubsequence(self, text1: str, text2: str) -> int:
    dp=[0]*(len(text1)+1)
    for i in text2:
    flag = 0
    for j in range(len(text1)):
    if i==text1[j] and flag == 0:
    if dp[j+1]!=dp[j]+1:
    flag=1
    dp[j+1]=dp[j]+1
    else:
    if dp[j+1]>=dp[j]:
    flag=0
    else:
    dp[j+1]=dp[j]

    return dp[-1]
    ``` I solved it in O(n) space complexity, beats 99% of the code in both time and memory distribution on leetcode

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

    @neetcode, are u left handed?

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

    1:04:00