Maximum Number of Moves in a Grid | Recursion | DP | Leetcode 2684

  Рет қаралды 2,497

Techdose

Techdose

Күн бұрын

Пікірлер: 20
@luvsharma2218
@luvsharma2218 2 күн бұрын
it is little bit simlar question like longest square streak which you have uploaded sir
@techdose4u
@techdose4u 2 күн бұрын
yep :) similar but in matrix and instead of 1 call you make 3 calls :)
@praveenabandari5971
@praveenabandari5971 Күн бұрын
Not all test cases are passing, Time limit exceeded.
@techdose4u
@techdose4u Күн бұрын
I checked just now. Its passing. Can you please match line by line to check if you missed pass by reference or something ?
@alessandrocamilleri1239
@alessandrocamilleri1239 Күн бұрын
Thanks for the great explanation. This is my dp solution using tabulation to save on recursion stack space: int maxMoves(vector& grid) { int m = grid.size(); int n = grid[0].size(); int maxMoves = 0; vector dp (m, vector(n, 0)); for (int i = 0; i < m; i++) dp[i][0] = 1; vector rowDelta {-1, 0, +1}; for (int i = 1; i < n; i++) { for (int j = 0; j < m; j++) { for (int r = 0; r < 3; r++) { int checkRow = j + rowDelta[r]; if (checkRow >= 0 && checkRow < m && grid[checkRow ][i-1] < grid[j][i] && dp[checkRow][i-1] == 1) { dp[j][i] = 1; maxMoves = i; } } } } return maxMoves; }
@techdose4u
@techdose4u Күн бұрын
Thanks :)
@sailendrachettri8521
@sailendrachettri8521 2 күн бұрын
@techdose4u
@techdose4u 2 күн бұрын
:)
@kgjr.6224
@kgjr.6224 Күн бұрын
sir just a suggestion but insted of solving and explaining the problem in the way where we will get the solution can you make it in the way that we can get the intution of how can we comeUp with those solution my our self like how the neetcode explains the solutions. Also you look very serious and not happy try to enjoy the process of problem solving.
@techdose4u
@techdose4u Күн бұрын
I am sleepy not serious 🥹 I just focus on the problem only. I would be chilling in a JOB if I wasnt enjoying this :) so peace!
@alessandrocamilleri1239
@alessandrocamilleri1239 Күн бұрын
@@kgjr.6224 I think he explained the algo thoroughly through the example. Obviously a good grasp of recursion is a prerequisite and it takes time to wrap your head around it. Techdose's content is very well curated with carefully pre-prepared slides to which he then adds explanations on the fly. He's up there with a few others. As for the "serious" expression, to each his own. Personally, I do not care as long as the content is of quality.
@kgjr.6224
@kgjr.6224 22 сағат бұрын
@@alessandrocamilleri1239 I am not saying he did not explain the problem or anything like that I am just saying that he started explaining the example right-away. My thought is like he should not explain the ans but how we as common beings existing in this world should get to that solution by our self. The intuition behind the problem. According to me the motive of DSA question is never solving the problem but its why the solution works. why the simple brute force will not work and getting the concept like why we used 2d Array not hashMap like these kind of things. Have you ever watched the videos of Ariyan mittal. try his videos then you might get what I am talking about. I am no hater I am just giving constructive criticism.
@kgjr.6224
@kgjr.6224 22 сағат бұрын
@@techdose4u And Sir I am not saying you are not happy or not passionate about the thing you are doing. I know no one do these things just for timepass. I am just saying smile little bit in the videos it gives a happy vides because we are here to learn but there is no harm in being happy right.
@techdose4u
@techdose4u 21 сағат бұрын
I am happy 😃 Happier than ever. But maybe I look different while I am focussing 😅
@ahd-123z
@ahd-123z Күн бұрын
TLE problem ..
@techdose4u
@techdose4u Күн бұрын
dint pass ?
@dhananjayhirey2905
@dhananjayhirey2905 Күн бұрын
@@techdose4u no sir...not all TC's are passing
@ahd-123z
@ahd-123z Күн бұрын
@@techdose4u for very large grid ,the solution is suffering from TLE
Миллионер | 2 - серия
16:04
Million Show
Рет қаралды 1,8 МЛН
Kluster Duo #настольныеигры #boardgames #игры #games #настолки #настольные_игры
00:47
Longest Square Streak in an Array | Leetcode 2501
18:11
Techdose
Рет қаралды 2 М.
macOS: Essential Productivity Hacks for Developers
10:58
mehdio DataTV
Рет қаралды 11 М.
I Solved 1583 Leetcode Questions  Here's What I Learned
20:37
ThePrimeTime
Рет қаралды 708 М.
Should you grind LeetCode? feat. NeetCode | 051
56:22
Backend Banter
Рет қаралды 56 М.
I Solved 100 LeetCode Problems
13:11
Green Code
Рет қаралды 182 М.
Remove Sub Folders from the Filesystem | Leetcode 1233
20:59
Techdose
Рет қаралды 1,5 М.
Why Isn't Functional Programming the Norm? - Richard Feldman
46:09
Dynamic Programming isn't too hard. You just don't know what it is.
22:31
DecodingIntuition
Рет қаралды 188 М.
I Lost a Software Engineering Job Offer Overnight
13:49
Namanh Kapur
Рет қаралды 16 М.
Миллионер | 2 - серия
16:04
Million Show
Рет қаралды 1,8 МЛН