Cherry Pickup II - Leetcode 1463 - Python

  Рет қаралды 15,264

NeetCodeIO

NeetCodeIO

Күн бұрын

🚀 neetcode.io/ - A better way to prepare for Coding Interviews
🧑‍💼 LinkedIn: / navdeep-singh-3aaa14161
🐦 Twitter: / neetcode1
⭐ BLIND-75 PLAYLIST: • Two Sum - Leetcode 1 -...
Problem Link: leetcode.com/problems/cherry-...
0:00 - Read the problem
0:25 - Memoization Explanation
5:39 - Coding Memoization
11:01 - Memory Optimized DP Explanation
17:56 - Coding Memory Optimized DP
leetcode 1463
#neetcode #leetcode #python

Пікірлер: 38
@lPABLO_GAMING
@lPABLO_GAMING 4 ай бұрын
This is a certified Neetcode classic. thanks for continuing my streak 💯
@byduhlusional
@byduhlusional 4 ай бұрын
I'm trying to learn DP and every time I come across a daily problem with DP I watch your videos. I just want to say I appreciate you showing us the top down approach instead of going straight into using tabulation. It's more effort but it is appreciated.
@chrisnieves3881
@chrisnieves3881 4 ай бұрын
Amazon intern interview thursday pray for me mr neetcode please
@NeetCodeIO
@NeetCodeIO 4 ай бұрын
You got this!!! 💪
@miaowcat1
@miaowcat1 4 ай бұрын
In dfs, doing min, max(c1,c2) to check boundary is neat. Could probably apply in different problems like number of islands for boundary checks.
@BlunderArmour
@BlunderArmour 4 ай бұрын
Neato! I like your recursion to DP approach a lot. I got stuck at the DP solution when I tried to do it myself. But your video helps me understand how to develop the right way of thinking. Thank you!
@trihoang2863
@trihoang2863 4 ай бұрын
What a difficult problem. Thank you!
@jiteshpahwa266
@jiteshpahwa266 4 ай бұрын
Great explanation !! Thankyou :)
@pastori2672
@pastori2672 4 ай бұрын
lost my sanity trying to get the dp solution
@peachpink2831
@peachpink2831 4 ай бұрын
Since we have a symmetric matrix we can optimize the final approach even more by operating on just top right and bottom left triangle matrix alternatively. This will reduce the memory by half but will take longer to write.
@lPABLO_GAMING
@lPABLO_GAMING 4 ай бұрын
neato btw, the hint leetcode gave scared me. also i can see why you consider this problem to be easier than cherry pickup 1, looks like a nightmare
@ishanpadalkar9072
@ishanpadalkar9072 4 ай бұрын
Gave up trying to understand the code for the second approach lol. Will return with a fresher mind.
@karthikb547
@karthikb547 9 күн бұрын
Thanks man :)
@krateskim4169
@krateskim4169 4 ай бұрын
Thank you neato
@KnightMirkoYo
@KnightMirkoYo 4 ай бұрын
The memo approach fails with TLE in Java on the last test case, so I have to do DP and it's Sunday 😪 Thank you so much, couldn't do it without you.
@user-xz5iw1wf9w
@user-xz5iw1wf9w 4 ай бұрын
Nope it passes
@KnightMirkoYo
@KnightMirkoYo 4 ай бұрын
@@user-xz5iw1wf9w yeah, I had a bug which caused my memo array to do nothing. Now it's alright :)
@user-xz5iw1wf9w
@user-xz5iw1wf9w 4 ай бұрын
Can you please post video solutions of weekly contests it will be really helpful to understand those problems which we aren't able to solve .By seeing your videos we can easly upsolve the problem using initial hints during first half of the video
@aazzrwadrf
@aazzrwadrf 4 ай бұрын
this was the first hard i solved
@VijaySharma-nu5lz
@VijaySharma-nu5lz 4 ай бұрын
In the memoization approach(1st approach), can anyone tell me how to print the path of individual robots as well along with returning the results? Thanks.
@user-gs7xf6qt4l
@user-gs7xf6qt4l 4 ай бұрын
keeping a prev[][] matrix may help
@dingus2332
@dingus2332 4 ай бұрын
ah man , this was solvable , I just jumped to seeing the solution
@user-vu8jp3si2r
@user-vu8jp3si2r 4 ай бұрын
Why it should return 0 if c1 and c2 is same, instead of return maximum values from dfs(r+1, all possible column) ?
@NeetCodeIO
@NeetCodeIO 4 ай бұрын
We dont need to ever consider the case where c1 and c2 are the same, because it will never lead to the maximal result. I gave a short summary of why, it's basically a proof by contradiction.
@sdemji
@sdemji 4 ай бұрын
would it work to take the maximum cost route, remove it, then take the new maximum route again ? short answer : nope
@Pegasus02Kr
@Pegasus02Kr 4 ай бұрын
me seeing Neetcode's recursive solutions: "I can pretty much do it alone!" me seeing Neetcode's tabulation solution: "Forget it, I can't"
@user-vu8jp3si2r
@user-vu8jp3si2r 4 ай бұрын
Why it should return 0 if c1 and c2 is same, instead of return arr[r][c1] + 0 + maximum values from dfs(r+1, all possible column) ?
@clouds_304
@clouds_304 4 ай бұрын
I was wondering the same. But then i remembered he said in the beginning, the case where both robots land on zhe same grid will not be part of the best solution. So if it happens we just give up and return 0
@andrewqian9029
@andrewqian9029 4 ай бұрын
Neetcode if you can here me, please save me. I have interview tmrw morning, please lend me ur strength
@parikxit
@parikxit 4 ай бұрын
neat
@kirillzlobin7135
@kirillzlobin7135 4 ай бұрын
Leetcode 2267 Would be interesting to solve. Please please please
@deathbombs
@deathbombs 4 ай бұрын
I got this in first submission lol
@HuyLe-tu4pj
@HuyLe-tu4pj 4 ай бұрын
Is this a subchannel of Neetcode?
@NeetCodeIO
@NeetCodeIO 4 ай бұрын
yeah
@nikolaspische9378
@nikolaspische9378 4 ай бұрын
​@@NeetCodeIOHey what if i calculate the optional sum for robot 1 and marked the place which i have picked for optimal sum as visited and for the same calculate for robot2 but don't visit the already visited places and try finding out optimal sum for robot 2. at the end we can return Robot1 sum+ robot 2 sum . Is it goin to work???
@NeetCodeIO
@NeetCodeIO 4 ай бұрын
No, proof by contradiction: 1 1 1 10 1 1 10 1 100 Your robot 1 will take (1 + 1 + 100). Your robot 2 will take (1 + 1 + 1). But the answer is (1 + 10 + 10) + (1 + 1 + 100)
@furkanozbay
@furkanozbay 4 ай бұрын
@@nikolaspische9378 I had the same idea, thought run dfs for each robot (total 2) and spent much time to work it out but as NeetCode replied it will not lead to correct answer.
@akins4christ
@akins4christ 4 ай бұрын
@@NeetCodeIO def cherryPickUp(self, grid: List[List[int]]) -> int: NameError: name 'List' is not defined using vim editor
Meeting Rooms III - Leetcode 2402 - Python
16:16
NeetCodeIO
Рет қаралды 19 М.
Partition Array for Maximum Sum - Leetcode 1043 - Python
27:33
NeetCodeIO
Рет қаралды 16 М.
Vivaan  Tanya once again pranked Papa 🤣😇🤣
00:10
seema lamba
Рет қаралды 32 МЛН
1❤️
00:17
Nonomen ノノメン
Рет қаралды 13 МЛН
Khó thế mà cũng làm được || How did the police do that? #shorts
01:00
THEY WANTED TO TAKE ALL HIS GOODIES 🍫🥤🍟😂
00:17
OKUNJATA
Рет қаралды 20 МЛН
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 310 М.
Cherry Pickup II Leetcode Daily Challenge 1463 Cherry Pickup II
26:58
CS IITIAN - DSA
Рет қаралды 1,3 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 614 М.
K Inverse Pairs Array - Leetcode 629 - Python
29:44
NeetCodeIO
Рет қаралды 15 М.
Student Attendance Record II - Leetcode 552 - Python
27:10
NeetCodeIO
Рет қаралды 8 М.
Most Common Concepts for Coding Interviews
6:08
NeetCode
Рет қаралды 284 М.
Out of Boundary Paths - Leetcode 576 - Python
18:20
NeetCodeIO
Рет қаралды 15 М.
8 Design Patterns | Prime Reacts
22:10
ThePrimeTime
Рет қаралды 390 М.
Rearrange Array Elements by Sign - Leetcode 2149 - Python
10:25
Vivaan  Tanya once again pranked Papa 🤣😇🤣
00:10
seema lamba
Рет қаралды 32 МЛН