DP #39. Total Matrix Path Choices Right and Bottom movement - mbhushan/dynpro GitHub Wiki
(39). Total Matrix ways.
Given a 2 dimensional matrix, how many ways you can reach bottom
right from top left provided you can only move down and right.
Formula:
if (i == 0 || j == 0) {
T[i][j] = 1
} else {
T[i][j] = T[i-1][j] + T[i][j-1]
}
Time complexity: (n*m)
Space complexity: O(n*m)
indices | 0 | 1 | 2 | 3 |
---|---|---|---|---|
0 | 1 | 1 | 1 | 1 |
1 | 1 | 2 | 3 | 4 |
2 | 1 | 3 | 6 | 10 |
3 | 1 | 4 | 10 | 20(ans) |