Dynamic Programming 2D - Full Course - Python

Dynamic Programming 2D - Full Course - Python

NeetCode

1 год назад

104,280 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Oleksandr Poshtaruk
Oleksandr Poshtaruk - 07.09.2023 10:18

Thank you!

Ответить
Alimentacion Saludable
Alimentacion Saludable - 24.08.2023 22:34

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

Ответить
qrozes
qrozes - 06.06.2023 19:40

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

Ответить
Aryan Singh
Aryan Singh - 29.05.2023 09:20

Loved it thanks for the amazing explanations❤

Ответить
anilsai lakhinana
anilsai lakhinana - 08.05.2023 06:05

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]

Ответить
Aryan Singh
Aryan Singh - 01.04.2023 17:42

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

Ответить
Undaunted Research
Undaunted Research - 18.03.2023 17:59

@neetcode, are u left handed?

Ответить
Chrisogonas O. Mc'Odhiambo
Chrisogonas O. Mc'Odhiambo - 28.01.2023 04:37

Thanks lots for putting together this rich resource.

Ответить
RandomShowerThoughts
RandomShowerThoughts - 12.01.2023 06:03

this is so god damn complicated wtf

Ответить
pwnweb
pwnweb - 11.01.2023 07:43

nice good neatcode :)

Ответить
ML Guy
ML Guy - 07.01.2023 06:24

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

Ответить
Akhil
Akhil - 21.12.2022 20:44

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

Ответить
JJCUBER
JJCUBER - 17.12.2022 10:18

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.

Ответить
muhammad hassan razzaq
muhammad hassan razzaq - 13.11.2022 09:41

Thanks man .

Ответить
AnonymousCoward3000
AnonymousCoward3000 - 11.11.2022 03:49

Thanks!

Ответить
deathbombs
deathbombs - 04.11.2022 10:54

Naisu

Ответить
Google Account
Google Account - 25.10.2022 21:58

Please make video in dynamic programming in Java

Ответить
Dan Z
Dan Z - 14.10.2022 06:34

Christmas came early!

Ответить
Dennis Chukwunta
Dennis Chukwunta - 08.10.2022 11:42

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.

Ответить
Asutosh Satapathy
Asutosh Satapathy - 04.10.2022 07:15

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

Ответить
cose peter
cose peter - 02.10.2022 13:47

32. Longest Valid Parentheses can you solve this please?

Ответить
Uma's world
Uma's world - 01.10.2022 18:31

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.

Ответить
Mohamad Audhil
Mohamad Audhil - 01.10.2022 14:30

Superb!

Ответить
Sai Adigoppula
Sai Adigoppula - 28.09.2022 21:44

LeetCode 638 explanation plz

Ответить
Yueming Pang
Yueming Pang - 27.09.2022 21:00

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!

Ответить
Allen Zhao
Allen Zhao - 27.09.2022 04:28

This is insane! Thank you so much

Ответить
Lembueno8
Lembueno8 - 27.09.2022 03:51

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!

Ответить
prashanta saha
prashanta saha - 25.09.2022 21:18

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

Ответить
Sukanya Bag
Sukanya Bag - 24.09.2022 06:32

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

Ответить
Himanshu Chauhan
Himanshu Chauhan - 23.09.2022 21:31

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

Ответить
Gaurav Tiwari
Gaurav Tiwari - 21.09.2022 11:03

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

Ответить
Brayn
Brayn - 21.09.2022 07:03

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.

Ответить
RC
RC - 21.09.2022 00:14

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

Ответить
TheTruthsayer
TheTruthsayer - 20.09.2022 23:25

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

Ответить
Dip
Dip - 20.09.2022 21:02

Best coding channel. End of

Ответить
dorothy christina
dorothy christina - 20.09.2022 17:47

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

Ответить
Ziad Ahmed
Ziad Ahmed - 19.09.2022 17:04

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

Ответить
BRIGHT UP
BRIGHT UP - 19.09.2022 09:14

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

Ответить
Raghunandan Kavi
Raghunandan Kavi - 18.09.2022 20:08

Your explanation is better than anything i have see online

Ответить
Cong Minh
Cong Minh - 18.09.2022 19:49

Could you please publish greedy algorithms full course lecture?

Ответить
PV Hưng
PV Hưng - 18.09.2022 17:44

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.

Ответить
Jay
Jay - 18.09.2022 16:59

Yeah baby.❤

Ответить
Sidharth Dhiman
Sidharth Dhiman - 17.09.2022 18:18

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

Ответить
盧柏亨
盧柏亨 - 17.09.2022 11:46

Many thanks

Ответить
Estifanos Bireda
Estifanos Bireda - 16.09.2022 12:44

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

Ответить
Shubhakar05
Shubhakar05 - 16.09.2022 05:23

Man this guy is awesome

Ответить