DFS Approach - Stuck (C++)
Not able to clear all test cases, what am i doing wrong?\n\nvector<int> row = {-1, 0, 1, 0};\nvector<int> col = {0, 1, 0, -1};\n\nbool isVisited(int r, int c, v
Not able to clear all test cases, what am i doing wrong?\n```\nvector<int> row = {-1, 0, 1, 0};\nvector<int> col = {0, 1, 0, -1};\n\nbool isVisited(int r, int c, vector<vector<int>> &visited) {\n  if (visited[r][c] == 1)\n    return true;\n  return false;\n}\nint tm = 0 ;\nvoid help(vector<vector<int>> &grid, int i, int j, vector<vector<int>> &visited,\n          bool &flag, int &time) {\n\n // cout<<i<<" "<<j<<endl;\n  visited[i][j] = 1;\n  if(time < grid[i][j]){\n    return;\n  }\n\n  // cout << grid[i][j] << endl;\n  int n = grid.size();\n  int m = grid[0].size();\n\n  if (i == n - 1 && j == m - 1) {\n    // cout<< " base case"<<endl;\n    flag = true;\n    tm =  max(tm,time);\n    return;\n  }\n\n\n  for (int k = 0; k < 4; k++) {\n    int r = i + row[k];\n    int c = j + col[k];\n  \n    if (r >= 0 && r < n && c >= 0 && c < m ) {\n        \n      if (!isVisited(r, c, visited)) {\n          time ++;\n        // cout<<"Time : "<<time<<endl;\n        help(grid,r,c,visited,flag,time);\n        visited[r][c] = 0;\n        time--;\n      }\n    }  \n  }\n}\n```\n\nThank you!
['Depth-First Search', 'Recursion', 'C']