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 - Наука та технологія
I’m convinced your stuff is better than Algoexpert
bye 110% this guy is awesome
Why are you guys liking me lmao, like Neetcode instead
to be fair i have algoexpert and that shit is good
I think they are both GREAT. I love Clement so much but Neetcode definitely has way more content for free which I appreciate dearly
without a doubt.
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.
Ohh Man...you are great
Finally ....someone making so much comprehensive course on 2d mtrix
Hi Bro.Please do a full course on graph problems .It would be really helpful.This video is awesome 👌
Woow this is gem. Can you please please do a comprehensive video on Graph?
Your explanation is better than anything i have see online
A lot of these videos handwave things away, but these are really good solutions. Cheers
This is insane! Thank you so much
Thanks lots for putting together this rich resource.
Loved it thanks for the amazing explanations❤
literally you are the only one that i can complete his video without being bored
As a freshman in CS, dp is such a tall ask for me to overcome. And this series save me... respect for neetcode!
Awesome, thanks!
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!
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.
That's awesome, congratulations on the offer!! And thanks for the kind words :)
If I learn something from this video, I’m definitely signing up for lifetime access
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.
Well put
Man this guy is awesome
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.
Thank you!
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
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
Thank you🙏
awesome!!
Thanks man .
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.
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
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?
Christmas came early!
Hi, please make a lecture on LC 1626. Best Team With No Conflicts! Love your way of teaching!!
Please do more videos on frequently asked questions in Maang interviews on leetcode.
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)
nice good neatcode :)
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.
Have you thought about adding Swift language solutions on your website?
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.
Thanks!
Thank you so much 🙏🙏🙏
WOOOW!
typo in the problem Distinct subsequences. It should be dfs(i+1,j) instead of dfs(i+i,j) in line 14 and 16
11:50 LCS
30:00 stock selling
45:00 coin change
Please make video in dynamic programming in Java
Yeah baby.❤
Dope
awesome
Can you please consider to extend the discount sale upto end of this month.
is 2d array dp and pointer approach the same time complexity?
Best coding channel. End of
Hey could you please make a video on LC problem number 273
godly
thanx man , when will be the system design course coming ?
Hopefully by end of October, but I will try to upload it as I complete each lesson
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.
I definitely had to look at the solution a lot when I first started
@@NeetCode Thank you, appreciate your time and response. :)
Edit Distance: What if we have fourth option is exchange two adjacent character?
gaw damnn 3 hrs for 2d dp
Hey neetcode please solve the problem no 1478 of leetcode largest continuous subaaray with abs diff les than limit
Shortest Path in Binary Matrix can you please solve this question leetcode 1091
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]
Superb!
Naisu
I am the winner today
why did burst ballon become max coins?
32. Longest Valid Parentheses can you solve this please?
LeetCode 638 explanation plz
Many thanks
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!
since you are doing not strictly leetcode and all
1:38:00
When is the sale gonna last until?
About 1 more week
@@NeetCode what is difference of the content on your UA-cam channel and your paid subscription on your website?
Could you please publish greedy algorithms full course lecture?
Got TLE for burst balloons
in C++, got TLE while using map for caching. Got accepted by using vector for caching
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
These questions are from 150 LC list , even his normal videos feel really premium :D
These solutions are already available for free, I just compiled them into one video
@@NeetCode ohh thanks for your reply☺☺
@@cyberserker yes because of him i am able to solve problems. We all need teachers like him at some point in our life
first!!!! i am the first
this is so god damn complicated wtf
```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
If you want me to explain let me know
@neetcode, are u left handed?
1:04:00