Correction : Video-10 This video is Long and Super Detailed because i want it to be beginner friendly. If you want to skip to topics, use the pointers below : ✨ Timelines✨ 00:00 - Introduction 00:12 - Motivation (Bhashan) 01:08 - Understand Problem 05:31 - Thought Process 05:55 - Tree Diagram 17:12 - Code Trust in Recursion 31:45 - Time Complexity 35:13 - Space Complexity 37:22 - Coding it up Thank you all ❤❤❤
vector findPath(vector &mat, int n = -1) { if (n == -1) { n = mat.size(); // Automatically determine the size of the matrix } result.clear(); // Clear previous results string temp = ""; if (mat[0][0] == 0 || mat[n - 1][n - 1] == 0) { return result; } solve(0, 0, mat, n, temp); return result; } this is maybe a correction because in my gfg i was not able to submit the findPath wala code you told, and the driver code is never editable.
First Time exploring this questions , always avoided thinking that I will never able to understand this coz of some tutuorial (complecated) but I am pretty sure that this is going to be me last stop I hava not only understood this but I am confident enough that I will be able to explain this question to anyone ! I will never forget the approch thank you for making this so easy mik !😊 could't thank you enough for these amazing content !
Already solve this problem in last year and also solve today also but your vedio is something special i repeat watch it, You not only solve problem U give the direction of brainstorming to start making intution and the dry run part is the most lovely one. I have no word just say Love U Three Thousand.
I binged watched all the videos in this playlist. Waiting for more videos in this playlist. Bring more such concepts playlist for bit manipulation also
The below code is for those who are still struggling to understand the code, the below approach is divided into sub parts to understand how the code is working in a vocal manner. For eg. we each time check if the next position (L,R,U,D) we are going to move, is that next position actually valid? if yes, then only that position will get called by the recursive function, and if its not valid, then it'll proceed to the next if statements respectively. Note : No Time or Space complexity is taken into consideration for the below code, its just for the understanding for oneself. Thanks :) CODE :- #include using namespace std; bool isValid(vector< vector >& maze, vector< vector >& visited, int i, int j){ if(i < 0 || j < 0 || i >= maze.size() || j >= maze[0].size()) return false; else if( maze[i][j] == 0 ) return false; else if(visited[i][j] == 1) return false; else return true; } void ratInMaze(vector< vector >& maze, vector< vector >& ans, string& path, vector< vector >& visited, int i, int j){ int row = maze.size(); int col = maze[0].size(); // base case: reaching the bottom-right corner if (i == row - 1 && j == col - 1) { ans.push_back({path}); return; } visited[i][j] = 1; // Up // if this 'if' statement is valid for UP, then only execute this 'if' block. Likewise goes for the below if blocks :) if( isValid(maze,visited,i-1,j) ){ path.push_back('U'); ratInMaze(maze, ans, path, visited, i-1, j); path.pop_back(); } // Right if( isValid(maze,visited,i,j+1) ){ path.push_back('R'); ratInMaze(maze, ans, path, visited, i, j+1); path.pop_back(); } // Down if( isValid(maze,visited,i+1,j) ){ path.push_back('D'); ratInMaze(maze, ans, path, visited, i+1, j); path.pop_back(); } // Left if( isValid(maze,visited,i,j-1) ){ path.push_back('L'); ratInMaze(maze, ans, path, visited, i, j-1); path.pop_back(); } visited[i][j] = 0; } int main(){ vector< vector > maze = { {1,0,0,0}, {1,1,0,1}, {1,1,1,1}, {1,1,1,1} }; string path = ""; vector< vector > ans; int i = 0, j = 0; int row = maze.size(); int col = maze[0].size(); vector visited(row, vector(col, 0)); ratInMaze(maze, ans, path, visited,i, j); for(auto it : ans){ for(auto jt : it) cout
bhaiya thanks a lot abhi mai apki arrays ki playlist kar ra jald hi after that recursion dp padunga apse maine recursion ke lec nhi kare but me yeh kehe sakta hu ki yin 11 videos mai apne recursion pura samja diya hoga 💯 . if possible dbms sql ka dekh sakte ho kya abhi coding rounds mai sql + dsa aise question are cognizant , accenture mai
Correction : Video-10
This video is Long and Super Detailed because i want it to be beginner friendly. If you want to skip to topics, use the pointers below :
✨ Timelines✨
00:00 - Introduction
00:12 - Motivation (Bhashan)
01:08 - Understand Problem
05:31 - Thought Process
05:55 - Tree Diagram
17:12 - Code Trust in Recursion
31:45 - Time Complexity
35:13 - Space Complexity
37:22 - Coding it up
Thank you all ❤❤❤
mik ,long videos hi chaie aapke. no one details like you. bring more super detailed videos. thanks for stressing on time and space complexity
vector findPath(vector &mat, int n = -1) {
if (n == -1) {
n = mat.size(); // Automatically determine the size of the matrix
}
result.clear(); // Clear previous results
string temp = "";
if (mat[0][0] == 0 || mat[n - 1][n - 1] == 0) {
return result;
}
solve(0, 0, mat, n, temp);
return result;
}
this is maybe a correction because in my gfg i was not able to submit the findPath wala code you told, and the driver code is never editable.
I wish I had got this channel 1-2 years back when I first started DSA
Same
First Time exploring this questions , always avoided thinking that I will never able to understand this coz of some tutuorial (complecated) but I am pretty sure that this is going to be me last stop I hava not only understood this but I am confident enough that I will be able to explain this question to anyone !
I will never forget the approch thank you for making this so easy mik !😊 could't thank you enough for these amazing content !
koi itni easy way mai kaise samjha sakta hai yrr....
teaching level++;
your thoughts and motivation really makes your videos special
Already solve this problem in last year and also solve today also but your vedio is something special i repeat watch it, You not only solve problem U give the direction of brainstorming to start making intution and the dry run part is the most lovely one.
I have no word just say Love U Three Thousand.
Most welcome 😊
I binged watched all the videos in this playlist. Waiting for more videos in this playlist. Bring more such concepts playlist for bit manipulation also
Thank you for simplifying it so well😇
Great explanation
Glad it was helpful! ❤️
Motivation is awesome ❤
The below code is for those who are still struggling to understand the code, the below approach is divided into sub parts to understand how the code is working in a vocal manner.
For eg. we each time check if the next position (L,R,U,D) we are going to move, is that next position actually valid? if yes, then only that position will get called by the recursive function, and if its not valid, then it'll proceed to the next if statements respectively.
Note : No Time or Space complexity is taken into consideration for the below code, its just for the understanding for oneself. Thanks :)
CODE :-
#include
using namespace std;
bool isValid(vector< vector >& maze, vector< vector >& visited, int i, int j){
if(i < 0 || j < 0 || i >= maze.size() || j >= maze[0].size()) return false;
else if( maze[i][j] == 0 ) return false;
else if(visited[i][j] == 1) return false;
else return true;
}
void ratInMaze(vector< vector >& maze, vector< vector >& ans, string& path, vector< vector >& visited, int i, int j){
int row = maze.size();
int col = maze[0].size();
// base case: reaching the bottom-right corner
if (i == row - 1 && j == col - 1) {
ans.push_back({path});
return;
}
visited[i][j] = 1;
// Up
// if this 'if' statement is valid for UP, then only execute this 'if' block. Likewise goes for the below if blocks :)
if( isValid(maze,visited,i-1,j) ){
path.push_back('U');
ratInMaze(maze, ans, path, visited, i-1, j);
path.pop_back();
}
// Right
if( isValid(maze,visited,i,j+1) ){
path.push_back('R');
ratInMaze(maze, ans, path, visited, i, j+1);
path.pop_back();
}
// Down
if( isValid(maze,visited,i+1,j) ){
path.push_back('D');
ratInMaze(maze, ans, path, visited, i+1, j);
path.pop_back();
}
// Left
if( isValid(maze,visited,i,j-1) ){
path.push_back('L');
ratInMaze(maze, ans, path, visited, i, j-1);
path.pop_back();
}
visited[i][j] = 0;
}
int main(){
vector< vector > maze = {
{1,0,0,0},
{1,1,0,1},
{1,1,1,1},
{1,1,1,1}
};
string path = "";
vector< vector > ans;
int i = 0, j = 0;
int row = maze.size();
int col = maze[0].size();
vector visited(row, vector(col, 0));
ratInMaze(maze, ans, path, visited,i, j);
for(auto it : ans){
for(auto jt : it) cout
bhaiya thanks a lot abhi mai apki arrays ki playlist kar ra jald hi after that recursion dp padunga apse
maine recursion ke lec nhi kare but me yeh kehe sakta hu ki yin 11 videos mai apne recursion pura samja diya hoga 💯 .
if possible dbms sql ka dekh sakte ho kya abhi coding rounds mai sql + dsa aise question are cognizant , accenture mai
Sir matrix chain multiplication pattern pe video lao
10/18 done [14.5.24]✅✅
@codestorywithMIK Can you please explain why will BFS not work here.
Thanks.
sir is wle question me for loop use nhi kar sakte jaise aapne previous question me batiya hai 4 direction ko expolre karne ke liye vector le kar ?
Yes definitely you can use for loop. Just make sure that if you go UP , you append “U”, if you go down you append “D” and so on.
@codestorywithMIK Thanks, sir
Mik bhai hum solve k age check laga k recursion call kar sakte kya ,it means if(m[I][j-1] ==1 ) solve(...) Like
The best ❤❤
Thank you so much.
Sir please explain the java code given in the link
there should be condition that m[n-1][n-1]!=0
23:00
❤❤❤
Cfbr
❣❣
Bhai ek heart de do
❤️
og level explaination