Rat Maze With Multiple Jumps Geeks For Geeks
Problem: https://practice.geeksforgeeks.org/problems/rat-maze-with-multiple-jumps3852/1# (It is also the problem of the day for 02-06-2022) Solution: class Solution { public int[][] ShortestDistance(int[][] matrix) { int[][] t=new int[matrix.length][matrix[0].length]; for(int i=0;i<matrix.length;i++){ for(int j=0;j<matrix[0].length;j++){ t[i][j]=0; } } if(check(matrix,t,0,0)==true){ return t; } else{ int a[][]=new int[1][1]; for(int i=0;i<1;i++){ for(int j=0;j<1;j++){ a[i][j]=-1; } } return a; } } public static boolean boundary(int i, int j, int[][] matrix){ if(i>=matrix.length || j>=matrix[0].length || matrix[i][j]==0){ return false; } return true; } public static boolean check(int[][] matrix, int[][] t, int i, i