Unique Paths | Dynamic programming | Leetcode #62

  Рет қаралды 61,836

Techdose

Techdose

Күн бұрын

Пікірлер: 150
@saurabhsomani9188
@saurabhsomani9188 4 жыл бұрын
Somebody give this man a medal ASAP. Crystal clear explanations on each and every problem. Very Inspiring and Helpful.
@techdose4u
@techdose4u 4 жыл бұрын
🤣 Hahahahaa.....Thanks for appreciating :D
@dumbcurious450
@dumbcurious450 4 жыл бұрын
Everyone starts with matrix directly no one says why this would work. this Man is someone who tells the exact logic behind it. Great work Mate ...
@techdose4u
@techdose4u 4 жыл бұрын
Thanks :)
@rahulbawa3969
@rahulbawa3969 3 жыл бұрын
Its been 10 months and this Guy still hasn't received a medal!!!! You deserve it man! Thanks for explaining this nicely.
@techdose4u
@techdose4u 3 жыл бұрын
Welcome :)
@savvy9431
@savvy9431 3 жыл бұрын
This is how a coding problem should be explained.............. Everybody needs to learn from this man right here.!!!!!! Hats off🎉🎉
@VrickzGamer
@VrickzGamer 4 жыл бұрын
I like Your Dark theme in the videos which gives my eyes the power to view more.
@venkateshmusuvathi8468
@venkateshmusuvathi8468 3 жыл бұрын
Salute to ANYONE who gets this interview question and solves it within half n hr
@imshivendra
@imshivendra 2 жыл бұрын
I think TechDose Sir has joined Google. Congratulations.
@thiyagarajanr225
@thiyagarajanr225 4 жыл бұрын
This man is so good at segementing the problems ! More power to you bro! A Die hard fan of you bro 💗
@techdose4u
@techdose4u 4 жыл бұрын
Thanks :)
@imshivendra
@imshivendra 2 жыл бұрын
I think TechDose Sir has joined Google. Congratulations.
@ashishupadhyay6881
@ashishupadhyay6881 4 жыл бұрын
Start watching at 10:40. Great stuff btw, thanks for this.
@HemanthaKumarYadav
@HemanthaKumarYadav 3 жыл бұрын
Most underrated channel ! Hatsoff to you brother !
@techdose4u
@techdose4u 3 жыл бұрын
Thanks :)
@rutachaudhari5774
@rutachaudhari5774 3 жыл бұрын
You are way underrated for your work. Thanks for the solutions!
@techdose4u
@techdose4u 3 жыл бұрын
Welcome :)
@lavanya_m01
@lavanya_m01 3 жыл бұрын
This universe needs people like him!! Protect him :)
@sudhanshukumar1558
@sudhanshukumar1558 4 жыл бұрын
I have already solved this problem 2 months back, hence I copied my code from there. It was bottom up approach. Good to know about the top down approach.
@techdose4u
@techdose4u 4 жыл бұрын
I had shown bottom up in dungeon game and so I took top down this time XD
@CostaKazistov
@CostaKazistov 2 жыл бұрын
Top-down DP runs slightly faster (for some reason)
@maansi3968
@maansi3968 4 жыл бұрын
The Explanation is soo great....just came through an one line python solution. return math.factorial(A+B-2)//(math.factorial(A-1)*math.factorial(B-1))
@techdose4u
@techdose4u 4 жыл бұрын
Thanks
@aminumado6973
@aminumado6973 2 жыл бұрын
Best explanation for the unique paths problem.
@md_aaqil8027
@md_aaqil8027 4 жыл бұрын
Mind-blowing Explanation I am a fan of the way you think and solve the problem bro
@imshivendra
@imshivendra 2 жыл бұрын
I think TechDose Sir has joined Google. Congratulations.
@Ayush-xx1bx
@Ayush-xx1bx 3 жыл бұрын
Can't thank you enough, I was stuck for hours with this approach. Now I understand it completely.
@imshivendra
@imshivendra 2 жыл бұрын
I think TechDose Sir has joined Google. Congratulations.
@adityagoswami6881
@adityagoswami6881 4 жыл бұрын
The best explanation,you deserve 1 Million subscriber .
@techdose4u
@techdose4u 4 жыл бұрын
Thanks ❤️
@imshivendra
@imshivendra 2 жыл бұрын
I think TechDose Sir has joined Google. Congratulations.
@RohitSubedi
@RohitSubedi 4 жыл бұрын
You can minimise the space complexity to O(M). Following is the Golang code: func uniquePaths(m int, n int) int { grid := make([]int, m) for i := 0; i < n; i++ { for j := 0; j < m; j++ { if i == 0 || j == 0 { grid[j] = 1 } else { grid[j] = grid[j] + grid[j-1] } } } return grid[m-1] }
@techdose4u
@techdose4u 4 жыл бұрын
We can optimize the space even in CPP by just maintaining a single array because we are just looking at 2 previous values :) top and left.
@rubinluitel158
@rubinluitel158 4 жыл бұрын
how is this better? if you have have an array size 5, it executes 5^2 times for the videos solution but your solution also executes 25 times.
@vaishnavinatarajan3987
@vaishnavinatarajan3987 Жыл бұрын
Simple solution and awesome explanation ! Too helpful.
@oqant0424
@oqant0424 2 жыл бұрын
Ur channel is a goldmine
@imshivendra
@imshivendra 2 жыл бұрын
I think TechDose Sir has joined Google. Congratulations.
@shubhammishra1225
@shubhammishra1225 2 жыл бұрын
bohat shi samjhaya ...
@hariprakash4237
@hariprakash4237 Жыл бұрын
Sucessfully completed. Thanks for this workout
@techdose4u
@techdose4u Жыл бұрын
Welcome :)
@rogerknight8447
@rogerknight8447 4 жыл бұрын
By combinatorics its like (m+n-2)C(n-1). An better SC approach though!!
@tecocode6070
@tecocode6070 4 жыл бұрын
Roger Knight how you explain this approach?
@sulekhakumari-hs4gy
@sulekhakumari-hs4gy 4 жыл бұрын
@@tecocode6070 this problem is eqivalent to permute (m-1) down move and (n-1)right move.
@saitejdandge2315
@saitejdandge2315 4 жыл бұрын
Let's say, we have r X c matrix. Let's take a simple way, all down, then all right, steps=r-1(down) + c-1 (right). Ironically every other way also takes r-1+c-1 steps. total ways is nothing but all permutations of given way (r+c-2) => (r-1+c-1)! / (r-1)! * (c-1)! => can be re written as (m+n-2)C(n-1)
@siddusidh9705
@siddusidh9705 23 күн бұрын
very good explanation , thanks a lot you are genius
@DK-ox7ze
@DK-ox7ze 4 жыл бұрын
Best explanation of this problem anywhere!
@techdose4u
@techdose4u 4 жыл бұрын
Thanks :)
@imshivendra
@imshivendra 2 жыл бұрын
I think TechDose Sir has joined Google. Congratulations.
@DK-ox7ze
@DK-ox7ze 2 жыл бұрын
@@imshivendra What's his real name?
@imshivendra
@imshivendra 2 жыл бұрын
@@DK-ox7ze I don't know but I has seen on LinkedIn that he has joined Google
@dhanashreegodase4445
@dhanashreegodase4445 3 жыл бұрын
very helpful to me! thanks alot..You deserve many more likes
@techdose4u
@techdose4u 3 жыл бұрын
Thanks
@agileprogramming7463
@agileprogramming7463 4 жыл бұрын
One of the easiest DP problems 😅 Also the Robot in thumbnail is 😍
@kunalsoni7681
@kunalsoni7681 4 жыл бұрын
Really you make this problem very easy to understand 😊😇.. thanking you sir 😊
@techdose4u
@techdose4u 4 жыл бұрын
Welcome :)
@ajaywadhwa3398
@ajaywadhwa3398 4 жыл бұрын
What a superb explanations !! Really helped a lot.
@techdose4u
@techdose4u 4 жыл бұрын
Thanks
@NikhilKumar-of5gb
@NikhilKumar-of5gb 4 жыл бұрын
Code with time complexity O(1) Code is like, nCr:-> Where, n=rows + columns -2 r = columns -2
@Rahul-rp5hk
@Rahul-rp5hk 4 жыл бұрын
How will you calculate ncr in O(1)? I guess it ll be O(r)
@MrMarchador
@MrMarchador 2 жыл бұрын
Very precise, clear, crisp explanation.
@sathyamoorthy2888
@sathyamoorthy2888 Жыл бұрын
Iam grateful to your service sir
@TONETHAJI
@TONETHAJI Жыл бұрын
Great explaination
@ashutoshsinghrajawat6440
@ashutoshsinghrajawat6440 4 ай бұрын
Simply amazing ❤
@yatri6329
@yatri6329 3 жыл бұрын
This video is a great explanation thanks for uploading this free....
@techdose4u
@techdose4u 3 жыл бұрын
Welcome 😊
@shobhitbajaj9667
@shobhitbajaj9667 4 жыл бұрын
Thank you so so much You have such a great talent ❤️ of explaining complex things like piece of cake.
@techdose4u
@techdose4u 4 жыл бұрын
Welcome :)
@nandk45523
@nandk45523 2 жыл бұрын
Great explanation bro appreciate it
@Tarunkumar-si4im
@Tarunkumar-si4im 3 жыл бұрын
Thanks a lot sir for crystal clean explanation❣️
@techdose4u
@techdose4u 3 жыл бұрын
Welcome :)
@imshivendra
@imshivendra 2 жыл бұрын
I think TechDose Sir has joined Google. Congratulations.
@ALEEMKHAWAR1
@ALEEMKHAWAR1 2 жыл бұрын
amazing solution sir
@ShubhamMahawar_Dancer_Actor
@ShubhamMahawar_Dancer_Actor 4 жыл бұрын
Its a cool solution but i have done it without recursion or Dp.I have done it by using binomial coefficient in which s.c=O(1)
@techdose4u
@techdose4u 4 жыл бұрын
Share your code bro :)
@manishmundra8902
@manishmundra8902 3 жыл бұрын
You deserve more likes sir..
@techdose4u
@techdose4u 3 жыл бұрын
Thanks :)
@bendesmedt9036
@bendesmedt9036 3 жыл бұрын
Nice, you could also solve it using combinatorics: [ (rows - 1) + (columns - 1) ] ! / [ (rows - 1) ! * (columns - 1) ! ]
@imshivendra
@imshivendra 2 жыл бұрын
I think TechDose Sir has joined Google. Congratulations.
@CostaKazistov
@CostaKazistov 2 жыл бұрын
@@imshivendra I wouldn't be surprised. He is truly one of the best CS teachers here on KZbin. The guy who runs a similar channel (NeetCode) has also started working for Google last year.
@noobCoder26
@noobCoder26 3 жыл бұрын
thanks sir for this explaination
@techdose4u
@techdose4u 3 жыл бұрын
Welcome :)
@PriyankaSingh-pn8xv
@PriyankaSingh-pn8xv 3 жыл бұрын
Amazing explanation, thanks
@275phuongvy
@275phuongvy 3 жыл бұрын
great explanation. Thank you
@techdose4u
@techdose4u 3 жыл бұрын
Welcome
@SuganthanMadhav
@SuganthanMadhav 4 жыл бұрын
Excellent explanation
@techdose4u
@techdose4u 4 жыл бұрын
Thanks :)
@acxd
@acxd 4 жыл бұрын
What are the Plans for July , another Challenge or Topic-wise !
@techdose4u
@techdose4u 4 жыл бұрын
Topicwise graph algorithm.
@nileshsinha7869
@nileshsinha7869 3 жыл бұрын
GREAT EXPLANATION SIR ❤👌
@techdose4u
@techdose4u 3 жыл бұрын
Thanks
@imshivendra
@imshivendra 2 жыл бұрын
I think TechDose Sir has joined Google. Congratulations.
@Moch117
@Moch117 Жыл бұрын
Nice video. Most videos start from f(m-1,n-1) i.e the bottom right but I solved it starting f(0,0) just like you I ask myself at each step : what can i do. I can either go down or go right. Then i ask what does my f(i,j) represent. In this case, it means the number of ways I can get to the bottom right starting at i and j. This means to calculate f(i,j), i need to know the number of ways I can get to bottom right if moved right + number of ways if I move down
@thegreekgoat98
@thegreekgoat98 2 жыл бұрын
The Best!
@ismail8973
@ismail8973 3 жыл бұрын
I literally loved this problem. Any way best explanation as always
@imshivendra
@imshivendra 2 жыл бұрын
I think TechDose Sir has joined Google. Congratulations.
@shresthmishra9329
@shresthmishra9329 4 жыл бұрын
Nice drawing 👌 😅
@spetsnaz_2
@spetsnaz_2 4 жыл бұрын
Robot is better than anything 😂🤖
@techdose4u
@techdose4u 4 жыл бұрын
Atleast someone understands art 😭
@saitejdandge2315
@saitejdandge2315 4 жыл бұрын
Let's say, we have r X c matrix. Let's take a simple way, all down, then all right, steps=r-1(down) + c-1 (right). Ironically every other way also takes r-1+c-1 steps. total ways is nothing but all permutations of given way (r+c-2) => (r-1+c-1)! / (r-1)! * (c-1)! => can be re written as (m+n-2)C(n-1)
@dontgiveup5271
@dontgiveup5271 3 жыл бұрын
Great explanation !!!! A small doubt at 13:32 I know from line 23 its used for fastIO but can I get some explanation on it. Thank You.
@imshivendra
@imshivendra 2 жыл бұрын
The height of a conical tank is 12cm and the diameter of its base is 32cm. The cost of painting if from outside at the rate of Rs 21 per sq. cm. is
@brandoncontreras343
@brandoncontreras343 3 жыл бұрын
THANK YOU!!!!!!
@techdose4u
@techdose4u 3 жыл бұрын
Thanks
@Tarunkumar-si4im
@Tarunkumar-si4im 3 жыл бұрын
👍👍
@techdose4u
@techdose4u 3 жыл бұрын
👍🏼
@prasantharavindramesh1078
@prasantharavindramesh1078 3 жыл бұрын
@techdose Awesome explanation Let's assume that the robot can move in all directions Then how can I modify the solution?
@techdose4u
@techdose4u 3 жыл бұрын
Assume it like a graph with 4 adjacent edges and then solve :)
@vibekdutta6539
@vibekdutta6539 4 жыл бұрын
Awesome, Sir what will be the complexity of we use combinatorics for the solution, I think there is a direct solution using combinatorics
@amanbarnwal6668
@amanbarnwal6668 3 жыл бұрын
Awesome content as always :) Just a simple query, at 4:07 I believe the recursive tree for node (1,0) in the right subtree is drawn wrong. Please correct me if I'm wrong.
@imshivendra
@imshivendra 2 жыл бұрын
I think TechDose Sir has joined Google. Congratulations.
@kamele0278
@kamele0278 2 жыл бұрын
what is the point of dynamic programming if you are not using recursion ?
@gaunikasrivastava7851
@gaunikasrivastava7851 3 жыл бұрын
What is time complexity of the recursive approach?
@bisatisrilatha7957
@bisatisrilatha7957 3 жыл бұрын
what is time complexity in recursive approach and DP ?????? why?????????
@saurabhkanswal7954
@saurabhkanswal7954 4 жыл бұрын
Not all heroes wear caps:)
@techdose4u
@techdose4u 4 жыл бұрын
:)
@E__ShameemahamedS-bx2ed
@E__ShameemahamedS-bx2ed 4 жыл бұрын
It's very similar to minimum cost path
@techdose4u
@techdose4u 4 жыл бұрын
Yea :)
@E__ShameemahamedS-bx2ed
@E__ShameemahamedS-bx2ed 4 жыл бұрын
@@techdose4u Pls explain what is bottom up approach and top down approach
@shyamprakashm6325
@shyamprakashm6325 4 жыл бұрын
Could we possible to print all the unique paths? If yes how it is?
@shivasaini4097
@shivasaini4097 3 жыл бұрын
@techdose4u
@techdose4u 3 жыл бұрын
😊
@muhammedjack8303
@muhammedjack8303 4 жыл бұрын
great
@techdose4u
@techdose4u 4 жыл бұрын
Thanks
@ASocial093
@ASocial093 4 жыл бұрын
Did you get leetcode s t-shirt previous month? I think you got it. 😁😁
@DreaMagnifier
@DreaMagnifier 4 жыл бұрын
it's standard combinatorics problem
@techdose4u
@techdose4u 4 жыл бұрын
👍
@vijayj1997
@vijayj1997 4 жыл бұрын
Can anyone explain , after breaking the dptable both robot and star are at same cell(0,0) then how the number of path will be 1?
@VrickzGamer
@VrickzGamer 4 жыл бұрын
how many are not from IIT/NIT/BITS ?
@E__ShameemahamedS-bx2ed
@E__ShameemahamedS-bx2ed 4 жыл бұрын
Me
@VrickzGamer
@VrickzGamer 4 жыл бұрын
Are you from NIT?
@shailygoyal5174
@shailygoyal5174 2 жыл бұрын
time n space complexity?
@HARINIKUMAR-qm3jc
@HARINIKUMAR-qm3jc Жыл бұрын
I tried doing Binary Tree in timestamp 4:17 myself and found that child from node (1,0) to be (1,1) & (2,0) but in the video it is given as (1,2) could you explain me how? Thanks in advance
@AlokDhanush-um5ol
@AlokDhanush-um5ol Жыл бұрын
Tha was a mistake in the video.. It must be (2, 0) instead of (1, 2)..
@HARINIKUMAR-qm3jc
@HARINIKUMAR-qm3jc Жыл бұрын
@@AlokDhanush-um5ol Thanks for taking time and replying :)
@backtobasics6865
@backtobasics6865 3 жыл бұрын
code link doesn.t opens
@snehan3341
@snehan3341 3 жыл бұрын
sir i cant understand how he says x and y are 3..? 2:50
@jeantharappel6633
@jeantharappel6633 Жыл бұрын
Why not just calculate (m+n-2)! / ( (m-1)! * (n-1)! )
@Moch117
@Moch117 Жыл бұрын
Not everyone knows this formula lol
@jeantharappel6633
@jeantharappel6633 11 ай бұрын
@@Moch117 it isn't a formula i used logic to covert the problem, consider m columns and n rows to get from one corner to another you need to move right (m-1) times and move down (n-1) times. The problem then becomes a permutations problem of which there are many variations. Say n is 3 and m is 4 and a down move is represented by d and a right move is represented by r. The number of permutations of rrrdd say rdrdr, rddrr etc is 5!/(3!*2!).
@krishnakantsharma6161
@krishnakantsharma6161 4 жыл бұрын
hve anyone noticed pattern in dp table 👀
@md_aaqil8027
@md_aaqil8027 4 жыл бұрын
Java Solution class Solution { public int uniquePaths(int m, int n) { int mat[][]=new int[n][m]; for(int i=0;i
@_Rich_YT_
@_Rich_YT_ 2 жыл бұрын
who is feeling frustrated now ??
Unique Paths 2 | Dynamic Programming | Leetcode #63
16:33
Techdose
Рет қаралды 26 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
А я думаю что за звук такой знакомый? 😂😂😂
00:15
Денис Кукояка
Рет қаралды 4,7 МЛН
За кого болели?😂
00:18
МЯТНАЯ ФАНТА
Рет қаралды 3,2 МЛН
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 20 МЛН
СКОЛЬКО ПАЛЬЦЕВ ТУТ?
00:16
Masomka
Рет қаралды 3,5 МЛН
Unique Paths - Leetcode 62 - Dynamic Programming (Python)
13:03
Greg Hogg
Рет қаралды 4,1 М.
Minimum edit distance | Dynamic programming | Backtracking
28:52
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 586 М.
Unique Paths II - Leetcode 63 - Python
14:31
NeetCodeIO
Рет қаралды 18 М.
Box Stacking Problem | Dynamic Programming | LIS
36:03
Techdose
Рет қаралды 28 М.
Dynamic Programming isn't too hard. You just don't know what it is.
22:31
DecodingIntuition
Рет қаралды 199 М.
А я думаю что за звук такой знакомый? 😂😂😂
00:15
Денис Кукояка
Рет қаралды 4,7 МЛН