Method
value
(int row, int col, int[][] dp)
Source from the content-addressed store, hash-verified
| 12 | } |
| 13 | |
| 14 | public int value(int row, int col, int[][] dp) { |
| 15 | if (row == 0 || col == 0 || col == row) return 1; |
| 16 | if (dp[row][col] != 0) return dp[row][col]; |
| 17 | dp[row][col] = value(row - 1, col - 1, dp) + value(row - 1, col, dp); |
| 18 | return dp[row][col]; |
| 19 | } |
| 20 | |
| 21 | /** Iterative approach to solving the problem - follows Neetcode's solution in Python |
| 22 | * O(n) time complexity |
Tested by
no test coverage detected