Unique Paths III -(Apple, Amazon, Microsoft, Intuit) : Explanation ➕ Live Coding

  Рет қаралды 4,998

codestorywithMIK

codestorywithMIK

Жыл бұрын

This is our 2nd Video on our Backtracking Playlist.
In this video we will try to solve a very Popular and a classical Backtracking Problem "Unique Paths III".
Share your learnings on LinkedIn, Twitter (X), Instagram, Facebook(Meta) with hashtag hashtag#codestorywithmik & feel free to tag me.
We will do live coding after explanation and see if we are able to pass all the test cases.
Problem Name : Unique Paths III
Company Tags : Apple, Amazon(on-site), Meta, Microsoft, Salesforce
My solutions on Github : github.com/MAZHARMIK/Intervie...
Leetcode Link : leetcode.com/problems/unique-...
My GitHub Repo for interview preparation : github.com/MAZHARMIK/Intervie...
Subscribe to my channel : / @codestorywithmik
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview #interviewtips #interviewpreparation #interview_ds_algo #hinglish

Пікірлер: 59
@prateekrath5098
@prateekrath5098 Жыл бұрын
Absolute Gold explanation as always. Happy new year brother, may god bless you with all the wealth, happiness and love. I hope you grow very big in the coming year, which I'm sure you will. Keep making these great explanations❤
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thank you so much Prateek. You made my day. Wish you also all the happiness and success in life ❤️❤️❤️
@rode_atharva
@rode_atharva 14 күн бұрын
sir graph ke questions kiye the to ye ho gaya, lekin appka video pura dekha to dimag me fix ho gaya ab.
@rajeshsinha290
@rajeshsinha290 4 ай бұрын
You explained the approach really well. I didn't even feel that it is a hard level question.
@souravjoshi2293
@souravjoshi2293 Жыл бұрын
Dope explanation man. Thanks a lot. No longer a Hard Problem. Happy New year bro Hope to be consistent like you in coming year
@ajiteshawasthi7311
@ajiteshawasthi7311 3 ай бұрын
Today first time I showed courage to solve hard problem without seeing solution , took me bit of time but I was able to solve it. Its all because of you brother. Thank you for your videos. You really are a gem.
@aakashtiwari8884
@aakashtiwari8884 Жыл бұрын
Been following your channel since last month, I finally received my first ever Leetcode badge today! Thanks for making all these questions feel easy, love your explanations and videos, thanks for doing this. keep posting you surely have miles to go! A very happy new year to you and yours!
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Hi Aakash, i am so happy with the news that you got the Leetcode badge. So happy for you. Keep it up and i will also continue it. Feel free to share your badge on LinkedIn or with your colleagues and help others achieve it too. It will strengthen your skill too. Thanks again ❤️❤️❤️
@EB-ot8uu
@EB-ot8uu 3 ай бұрын
You make Hard to Easy so effortlessly.
@svdfxd
@svdfxd 7 ай бұрын
Amazing explanation !!
@GeneralistDev
@GeneralistDev Жыл бұрын
holy shit!!! after watching your word search video (I just commented on that about that video few hours back) I was able to solve this question on my own .... totally surprised!!! I just coded casually and submitted in first attempt... can't believe...
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Woww. I am so glad. Very well done 👏
@OIAOa
@OIAOa 8 ай бұрын
enjoying a lot bhaiya❤
@aryanarora1984
@aryanarora1984 10 ай бұрын
you deserve a lot moree brother!! your way of explaining is awesome...
@codestorywithMIK
@codestorywithMIK 10 ай бұрын
Means a lot 😇❤️🙏
@sunnyvlogs__
@sunnyvlogs__ Жыл бұрын
Thanks Bhaiya, just saw the explanation and coded own. At first I was thinking of a solution like:- to calculate all the paths and store its (i,j) of that path in a vector. Then I will check the all the path vectors one by one and if its size is equal to the (size of the matrix(m*n) - given obstacles). then I will increase the count++. But while coding it was getting complicated. So followed this approach. Crystal Clear Explanation✨✨ Happy New Year Aapko. Tokopedia mein referral milega as a fresher😆
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thank you so much Sunny. ❤️❤️❤️ Indeed your earlier approach was also fine but it will get complicated as you mentioned. And currently, there is a hiring freeze unfortunately due to the world wide recession. But once it resumes (soon), i will be glad to refer all of you here. I am pretty sure you all are hard working and will rock wherever you guys go. Mean while, make the most of this time and prepare as much as possible so that when you start giving interviews you are READY 💪💪💪
@sunnyvlogs__
@sunnyvlogs__ Жыл бұрын
@@codestorywithMIKThank you Bhaiya , I will asking once recession is over. Yes Bhaiya preparing and practising regularly. Your videos are so much helpful.
@varunsheth1003
@varunsheth1003 Жыл бұрын
Happy New Year !!!!! Nice Explanation
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thank you so much ❤️❤️❤️
@user-vj3yw5nq7p
@user-vj3yw5nq7p 5 ай бұрын
Watching this video in New year 2024, happy new year :)
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
Happy new year! Thank you for watching 😇🙏❤️
@girikgarg8
@girikgarg8 9 ай бұрын
Nice explanation
@oqant0424
@oqant0424 Жыл бұрын
bhaiya u r a legit🔥🔥 i mean seriously hope we grow together this upcoming year ... a lots of success is coming in 2023 for us✨✨
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thank you so much ❤️❤️ Yeah, let’s grow together in 2023 Together we all can do it 💪💪💪
@devsharma181
@devsharma181 2 ай бұрын
nice explanation
@tauquirahmed1879
@tauquirahmed1879 Жыл бұрын
Why the heck watching your explanation is so interesting? I can watch your playlist like a web series....Love from Kolkata.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Wowwww. 😅 Thank you so so much ❤️❤️❤️
@souravjoshi2293
@souravjoshi2293 Жыл бұрын
True that 😆
@oqant0424
@oqant0424 Жыл бұрын
literally u r building great future coders! and i am one of them✌✌
@codestorywithMIK
@codestorywithMIK Жыл бұрын
We all will rock together soon 🙌💪💪❤️
@Ramneet04
@Ramneet04 8 ай бұрын
Hey how to differentiate wheather we can apply dp in it or not??? Well with question I completed my 300 leetcode questions 💪💪❤ thx a lot you have given amazing Content,like explanation is just out of the box❤.
@AnandKumar-kz3ls
@AnandKumar-kz3ls Жыл бұрын
Happy New Year bhai hoping to cross 10K in this year
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot Anand. ❤️❤️❤️ Means a lot
@keertilata20
@keertilata20 10 ай бұрын
you are the best!!!!!!!!!!!!!!!
@codestorywithMIK
@codestorywithMIK 10 ай бұрын
Means a lot 😇🙏
@thephalcon
@thephalcon Жыл бұрын
Continue sir
@pritishpattnaik4674
@pritishpattnaik4674 Жыл бұрын
Fantastic explanation Wrote the code without seeing void dfs(int i, int j, int count, int nonObstacle, vector& grid, int &ans){ int m = grid.size(); int n = grid[0].size(); //boundary cases if (i < 0 or i >= m or j < 0 or j >= n or grid[i][j] == -1){ return; } if (grid[i][j] == 2){ if (count == nonObstacle){ ans++; } return; } //visit the block grid[i][j] = -1; //call dfs in all 4 directions vector dir = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; for (auto x : dir){ int new_i = i + x[0]; int new_j = j + x[1]; dfs(new_i, new_j, count+1, nonObstacle, grid, ans); } //backtrack grid[i][j] = 0; } int uniquePathsIII(vector& grid) { int m = grid.size(); int n = grid[0].size(); int nonObstacle = 0; int start_x, start_y; for (int i=0 ; i
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Awesome ❤️❤️❤️
@piyushacharya7696
@piyushacharya7696 Жыл бұрын
Mera daily comment streak baal baal xutjata.😂😂 On leetcode, I received my first badge. all thanks to you👏
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Hi Piyush, i am so happy with the news that you got the Leetcode badge. So happy for you. Keep it up and i will also continue it. Feel free to share your badge on LinkedIn or with your colleagues and help others achieve it too. It will strengthen your skill too. Thanks again ❤️❤️❤️
@AmandeepSingh-uq3wp
@AmandeepSingh-uq3wp Жыл бұрын
Please sir kal se leetcode ke contest ke solutions explain karna start kariye. 🙏 Your explanations are really very good. 👍
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Hi Amandeep, due to time crunch, it’s in Queue. But soon. Thanks for your appreciation ❤️❤️❤️
@manishv.8167
@manishv.8167 Жыл бұрын
How Amazing You are !!!!!
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot Manish ❤️❤️❤️ Stay tuned for video-6 of Graph Concepts today Thanks for watching always ❤️❤️❤️
@manishv.8167
@manishv.8167 Жыл бұрын
@@codestorywithMIK thanks to restart it again
@oqant0424
@oqant0424 Жыл бұрын
u made a hard ques ssssssssssssooooooooooo easy!!!!!
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thank you so so much ❤️❤️❤️
@Raj10185
@Raj10185 Жыл бұрын
hii bhaiya one doubt how to check the question is of dp or backtracking since before this problem i am solving unique path 1 and 2 which is a dp problem and this is of backtraking can you give me some keywords so that i look at the question and then decide plz ? bcz once i know its backtraking i done simply by own how to find out which one of backtrcaking and which one of dp
@udaytewary3809
@udaytewary3809 10 ай бұрын
Hlo bhai see there is not any category of problem of dp the main thing is DP is used to optimise the recursion approach So if a problem is solvable using recursion then for sure DP will be applicable there And for backtracking part if we have been asked to try out all the possible ans and find the best one backtracking will be applicable
@dileshchouhan9527
@dileshchouhan9527 Жыл бұрын
bhaiya why are we not decrease count as well like when backtrack? i am confuse little bit pls explain :)
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Since we pass count+1 and hence value of count is not changed for next iteration of for loop. But if you want it just like backtracking You can change the code like backtracking below - for() { count++ Call recursion count- }
@svdfxd
@svdfxd 7 ай бұрын
The explanation is awesome. I have a question - in this code, where is the condition to stop counting the paths i.e. at what point do we stop? @codestorywithMIK
@hyperme1831
@hyperme1831 Ай бұрын
We are checking for starting points and for every starting point we are making dfs calls.. If there is no 1 we will stop
@hyperme1831
@hyperme1831 Ай бұрын
For suppose if there is only one 1 there will be only 1 recursive call on that 1 internally.. if there are two 1 s in matrix then there will be 2 dfs recursive calls from 2 starting points
@AnkushKumar-dd1jv
@AnkushKumar-dd1jv Ай бұрын
Aap bihar se ho?
@YashSinghal
@YashSinghal Жыл бұрын
hny :)
@codestorywithMIK
@codestorywithMIK Жыл бұрын
🙌❤️
@lakshsinghania
@lakshsinghania 8 ай бұрын
sir can u pls tell where im doing wrong in this and why this code is not working class Solution { public: int f(int i, int j, vector& grid, int di[], int dj[], vector& vis) { int m = grid.size(); int n = grid[0].size(); if(i = n || grid[i][j] == -1 || vis[i][j]) return 0; // Base case if (grid[i][j] == 2) { for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (grid[i][j] == 0 && !vis[i][j]) { return 0; } } } return 1; } int paths = 0; for (int k = 0; k < 4; k++) { int new_row = i + di[k]; int new_col = j + dj[k]; if (new_row >= 0 && new_col >= 0 && new_row < m && new_col < n && !vis[new_row][new_col] && grid[new_row][new_col] == 0) { vis[i][j] = 1; paths += f(new_row, new_col, grid, di, dj, vis); vis[i][j] = 0; } } return paths; } int uniquePathsIII(vector& grid) { int m = grid.size(); int n = grid[0].size(); int di[] = {-1, 0, 1, 0}; int dj[] = {0, 1, 0, -1}; // Make the visit matrix vector vis(m, vector(n, 0)); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (grid[i][j] == 1) { return f(i, j, grid, di, dj, vis); } } } return 0; // Return 0 if the ending position is not found. } }; pls sir help me ik backtracking but somewhat fail while implementing
Increíble final 😱
00:37
Juan De Dios Pantoja 2
Рет қаралды 114 МЛН
He sees meat everywhere 😄🥩
00:11
AngLova
Рет қаралды 10 МЛН
孩子多的烦恼?#火影忍者 #家庭 #佐助
00:31
火影忍者一家
Рет қаралды 40 МЛН
Unique Paths II - Leetcode 63 - Python
14:31
NeetCodeIO
Рет қаралды 13 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 611 М.
Unique Paths | Dynamic programming | Leetcode #62
13:59
Techdose
Рет қаралды 59 М.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 297 М.
House Robber | Recursion | Memo | Bottom Up | Leetcode 198
29:51
codestorywithMIK
Рет қаралды 9 М.
Increíble final 😱
00:37
Juan De Dios Pantoja 2
Рет қаралды 114 МЛН