Rat in a Maze Problem | Simple Story To Code | Recursion Concepts And Questions | Video 11

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ธ.ค. 2024

ความคิดเห็น • 35

  • @codestorywithMIK
    @codestorywithMIK  10 หลายเดือนก่อน +14

    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 ❤❤❤

    • @aws_handles
      @aws_handles 10 หลายเดือนก่อน +1

      mik ,long videos hi chaie aapke. no one details like you. bring more super detailed videos. thanks for stressing on time and space complexity

    • @shivanijhavats
      @shivanijhavats 11 วันที่ผ่านมา

      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.

  • @wearevacationuncoverers
    @wearevacationuncoverers 10 หลายเดือนก่อน +17

    I wish I had got this channel 1-2 years back when I first started DSA

  • @shubhamsingh4701
    @shubhamsingh4701 หลายเดือนก่อน +2

    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 !

  • @stalinpatel4051
    @stalinpatel4051 9 หลายเดือนก่อน +4

    koi itni easy way mai kaise samjha sakta hai yrr....
    teaching level++;

  • @nehasinghggpl9637
    @nehasinghggpl9637 3 หลายเดือนก่อน +1

    your thoughts and motivation really makes your videos special

  • @AnkitSingh-tm5dp
    @AnkitSingh-tm5dp 10 หลายเดือนก่อน +3

    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.

  • @EB-ot8uu
    @EB-ot8uu 10 หลายเดือนก่อน +1

    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

  • @ShachiSinghal-fi6uh
    @ShachiSinghal-fi6uh 5 หลายเดือนก่อน +1

    Thank you for simplifying it so well😇

  • @sahilanand30
    @sahilanand30 10 หลายเดือนก่อน +2

    Great explanation

    • @codestorywithMIK
      @codestorywithMIK  10 หลายเดือนก่อน +1

      Glad it was helpful! ❤️

  • @navdeepdhama403
    @navdeepdhama403 5 หลายเดือนก่อน +2

    Motivation is awesome ❤

  • @dumbstonks
    @dumbstonks 4 หลายเดือนก่อน +2

    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

  • @User-student-404
    @User-student-404 10 หลายเดือนก่อน +1

    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

  • @naitikraj9656
    @naitikraj9656 10 หลายเดือนก่อน +2

    Sir matrix chain multiplication pattern pe video lao

  • @oqant0424
    @oqant0424 7 หลายเดือนก่อน

    10/18 done [14.5.24]✅✅

  • @riyasinghal4758
    @riyasinghal4758 6 หลายเดือนก่อน

    @codestorywithMIK Can you please explain why will BFS not work here.
    Thanks.

  • @Greek_Bit_10
    @Greek_Bit_10 10 หลายเดือนก่อน

    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 ?

    • @codestorywithMIK
      @codestorywithMIK  10 หลายเดือนก่อน +1

      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.

    • @Greek_Bit_10
      @Greek_Bit_10 10 หลายเดือนก่อน

      @codestorywithMIK Thanks, sir

  • @footballcreativeeverywhere260
    @footballcreativeeverywhere260 10 หลายเดือนก่อน

    Mik bhai hum solve k age check laga k recursion call kar sakte kya ,it means if(m[I][j-1] ==1 ) solve(...) Like

  • @gauravbanerjee2898
    @gauravbanerjee2898 10 หลายเดือนก่อน

    The best ❤❤

  • @aws_handles
    @aws_handles 10 หลายเดือนก่อน

    Thank you so much.

  • @vaibhavsingh3468
    @vaibhavsingh3468 9 หลายเดือนก่อน

    Sir please explain the java code given in the link

  • @visheshpandey9070
    @visheshpandey9070 6 หลายเดือนก่อน +1

    there should be condition that m[n-1][n-1]!=0

  • @theonly_ashu
    @theonly_ashu 3 หลายเดือนก่อน

    23:00

  • @karangoswami3734
    @karangoswami3734 10 หลายเดือนก่อน +1

    ❤❤❤

  • @utkarshawasthi7748
    @utkarshawasthi7748 3 หลายเดือนก่อน +1

    Cfbr

  • @yashthakur5712
    @yashthakur5712 10 หลายเดือนก่อน

    ❣❣

  • @karangoswami3734
    @karangoswami3734 10 หลายเดือนก่อน +1

    Bhai ek heart de do

  • @secularguy________
    @secularguy________ 8 หลายเดือนก่อน

    og level explaination