intpath_helper(int i, int j, int m, int n, vector<vector<int>>& record, vector<vector<int>> &obstacleGrid){ if (i < 0 || j < 0 || obstacleGrid[i][j] == 1) { return0; }
if (record[i][j]) { return record[i][j]; }
if ((i == 0) && (j == 0)) { return1; }
record[i][j] = path_helper(i - 1, j, m, n, record, obstacleGrid) + path_helper(i, j - 1, m, n, record, obstacleGrid); return record[i][j]; }
intuniquePathsWithObstacles(vector<vector<int>>& obstacleGrid){ if (obstacleGrid.empty()) return0; int m = (int)obstacleGrid.size(); int n = (int)obstacleGrid[0].size();
vector<vector<int>> res(m, vector<int>(n, 0)); returnpath_helper(m - 1, n - 1, m, n, res, obstacleGrid); }