5
public int findPaths(int m, int n, int maxMove, int startRow, int startColumn) {6
dp = new int[m][n][maxMove + 1];7
for (int i = 0; i < m; i++)8
for (int j = 0; j < n; j++) for (int k = 0; k <= maxMove; k++) dp[i][j][k] = -1;9
return count(m, n, maxMove, startRow, startColumn) % mod;12
public int count(int m, int n, int move, int r, int c) {13
if (r < 0 || c < 0 || r >= m || c >= n) return 1;14
if (move <= 0) return 0;15
if (dp[r][c][move] != -1) return dp[r][c][move] % mod;17
((count(m, n, move - 1, r + 1, c) % mod + count(m, n, move - 1, r - 1, c) % mod) % mod18
+ (count(m, n, move - 1, r, c + 1) % mod + count(m, n, move - 1, r, c - 1) % mod)21
return dp[r][c][move] % mod;