Rat - Maze Problem | Backtracking | Print Rat Path

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ม.ค. 2025

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

  • @AdityaSharma-hy9iv
    @AdityaSharma-hy9iv 4 ปีที่แล้ว +3

    Love your videos, but can you please add some more videos on backtracking, Hashing, dp and also Graphs. One of the best channels I have learnt from. Your series on Trees is really great. Covered almost every question in trees!!!

    • @CodingSimplified
      @CodingSimplified  4 ปีที่แล้ว

      Sure, will try to add more videos on these topics. However in case you haven't seen, we have playlists of DP & Graph problems. Please watch those videos. Thanks.

    • @akashamin3954
      @akashamin3954 3 ปีที่แล้ว

      @@CodingSimplified I watched your tree, graph, linked list, stack, queue playlist, they are awesome, plz make a playlist on competitive programming too

  • @jeyamvenkat804
    @jeyamvenkat804 3 ปีที่แล้ว +2

    The source you mentioned will not work for the maze below
    You have to add two more movements one toward left and other towards up
    {{ 1, 0, 1, 1, 1 },
    { 1, 0, 1, 0, 1 },
    { 1, 0, 1, 0, 1 },
    { 1, 1, 1, 0, 1 } };

  • @DVadda-06kom
    @DVadda-06kom 7 หลายเดือนก่อน

    Thank you so much sir
    For simplified explanation.

  • @weltdeszagrozz6362
    @weltdeszagrozz6362 3 ปีที่แล้ว +2

    Well explained. Im from gernany and you helped me with that

    • @CodingSimplified
      @CodingSimplified  3 ปีที่แล้ว +1

      Thanks for your nice feedback. Keep watching.

  • @pqazx1
    @pqazx1 4 ปีที่แล้ว +4

    Plz add more problems..keep on uploading more videos ..

    • @CodingSimplified
      @CodingSimplified  4 ปีที่แล้ว

      Sure, will add more videos on Backtracking in coming days.

  • @nandhinirajavell9747
    @nandhinirajavell9747 4 ปีที่แล้ว +1

    Thanks for the video sir. Very good explanation. Can you please suggest on how to print all possible paths.

  • @sarthakshukla8416
    @sarthakshukla8416 4 ปีที่แล้ว +3

    Sir please make videos on bit algorithms , mathematics and greedy algorithms.

    • @CodingSimplified
      @CodingSimplified  4 ปีที่แล้ว +2

      Sure, will try to create videos on these topics. Thanks.

  • @vivekkumar-rm6im
    @vivekkumar-rm6im 4 ปีที่แล้ว +2

    Sir plzz add some videos realted to finding the complexility and how to calculate time complexity

    • @CodingSimplified
      @CodingSimplified  4 ปีที่แล้ว +1

      Ok, I'll try to add video on finding Time complexity soon. Thanks for your suggestion.

    • @vivekkumar-rm6im
      @vivekkumar-rm6im 4 ปีที่แล้ว

      Coding Simplified thanku so much sir🙏🏻

  • @arungiridharan3216
    @arungiridharan3216 3 ปีที่แล้ว

    Is Disjoint set a better approach?

  • @therealltrader2346
    @therealltrader2346 3 ปีที่แล้ว

    great explanation i've ever watched

    • @CodingSimplified
      @CodingSimplified  3 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching.

  • @ishitachawla9314
    @ishitachawla9314 4 ปีที่แล้ว +2

    if we want to print all the possible paths, then?

  • @rahhulk7
    @rahhulk7 3 ปีที่แล้ว +1

    Thanks, It helped!

    • @CodingSimplified
      @CodingSimplified  3 ปีที่แล้ว

      Thanks for your nice feedback. Keep Watching.

  • @dhivyasriselvakumar5741
    @dhivyasriselvakumar5741 4 ปีที่แล้ว

    In the prog in which part does the back tracking happens?? when down and side both are 0 that particular value is again changed to 0. After that in the code where the back track happens? Please answer.

    • @CodingSimplified
      @CodingSimplified  4 ปีที่แล้ว

      Hey, backtracking happens when you're going back from same path. In video we've explained where backtracking happening exactly. Please watch it once more & if you find the issue again let us know. Thanks

  • @abhishekmohan4405
    @abhishekmohan4405 2 ปีที่แล้ว +1

    Add more backtracking problems

    • @CodingSimplified
      @CodingSimplified  2 ปีที่แล้ว

      Thanks for your nice feedback. Sure, I'll try to more videos on it.

  • @its_dimri
    @its_dimri 4 ปีที่แล้ว

    i am not sure what all are the condition to Rat movement, but a little question
    check below matrix, there is a path for Rat but code fails...
    1 0 1 1 1 0
    1 1 1 0 1 0
    0 0 0 0 1 0
    0 0 1 1 1 0
    0 0 1 0 0 0
    0 0 1 1 1 1
    please clarify the Rat movement.
    or correct me if i am wrong.
    Code only check for the +1 col and +1 row... What if there is available path for rat to move above row or go to previous column

    • @parthsachan1130
      @parthsachan1130 3 ปีที่แล้ว

      the question has two restrictions: rat can move only right or in bottom direction, not left

  • @gajendralnmiit
    @gajendralnmiit 4 ปีที่แล้ว +2

    Another solution to solve this problem:-
    class Path {
    int x;
    int y;
    public Path(int i, int j) {
    x = i;
    y = j;
    }
    }
    public static void ratMazeProblem(int[][] arr) {
    pathing = new LinkedList();
    ratMazeProblem(arr, 0, 0);
    while (!pathing.isEmpty()) {
    System.out.print(pathing.removeFirst() + "->");
    }
    }
    private static void ratMazeProblem(int[][] arr, int i, int j) {
    if (i >= arr.length || j >= arr[0].length || arr[i][j] == 0 || flag) {
    return;
    }
    if (arr[i][j] == 1) {
    pathing.add(new Path(i, j));
    if (i == arr.length - 1 && j == arr[0].length - 1) {
    flag = true;
    return;
    }
    }
    ratMazeProblem(arr, i + 1, j);
    ratMazeProblem(arr, i, j + 1);
    if (!flag)
    pathing.removeLast();
    }

    • @CodingSimplified
      @CodingSimplified  4 ปีที่แล้ว

      Yup, that's is again nice answer. Thanks bro for adding another way of answering.

  • @KuldeepSahu-sq3cq
    @KuldeepSahu-sq3cq 3 ปีที่แล้ว

    sir only 3 ?

  • @teetanrobotics5363
    @teetanrobotics5363 4 ปีที่แล้ว +1

    Could you please add more backtracking videos.There are only 3

    • @CodingSimplified
      @CodingSimplified  4 ปีที่แล้ว

      Sure, will try to add more on it soon. Thanks for your suggestion & interest in channel.

    • @abhilashpatel3036
      @abhilashpatel3036 3 ปีที่แล้ว

      @@CodingSimplified Bro, nearly a year. Please add fews.