please tell me what's the issue in this code. it did not run ..???????? class Solution { public: bool solve(int i, int j, int n, int m, vector& matrix, vector& vis) { if (i == n - 1 && j == m - 1) { vis[i][j] = 1; return true; }
if (i < 0 || j < 0 || i >= n || j >= m || vis[i][j] == 1 || matrix[i][j] == 0) { return false; }
Problem: practice.geeksforgeeks.org/problems/rat-maze-with-multiple-jumps3852/1#
Solution Code in CPP:
vector ShortestDistance(vector&matrix){
// Code here
vectorans(matrix.size(),vector(matrix[0].size(),0));
if(!ratmaze(matrix,ans,0,0))
return {{-1}};
return ans;
}
bool withinboundary(int i,int j,vector&matrix)
{
if(i>=matrix.size() || j>=matrix[0].size() || matrix[i][j]==0)
return false;
return true;
}
bool ratmaze(vector&matrix,vector&ans,int i,int j)
{
if(i==matrix.size()-1 && j==matrix[0].size()-1)
{ ans[i][j]=1;
return true;
}
if(withinboundary(i,j,matrix))
{ ans[i][j]=1;
for(int noofsteps=1;noofsteps
Where is the main function
but currently, GFG is asking us to do it in space complexity of O(1). 😥
29. Divide Two Integers leetcode daily problem is hard to get it conceptually , pls make this one !
you are making medium problem easy
Very Very helpful
Thank you for logic and if you were also good in python please do programming in python aswell.
thanks , it was helpful
TC - O(R*C)?
Which playlist these questions are belong. I want to follow one playlist and complete that so l didn't find the upload questions playlist
this is problem of the day questions of GFG
@@AmanTheMystery ok thanks bro for replay
please tell me what's the issue in this code.
it did not run ..????????
class Solution {
public:
bool solve(int i, int j, int n, int m, vector& matrix, vector& vis) {
if (i == n - 1 && j == m - 1) {
vis[i][j] = 1;
return true;
}
if (i < 0 || j < 0 || i >= n || j >= m || vis[i][j] == 1 || matrix[i][j] == 0) {
return false;
}
vis[i][j] = 1;
int jumps = matrix[i][j];
for (int k = 1; k
thank you