Unique Paths
A robot is located at the Top-left corner of a m x n grid (marked ' Start ' in the diagram below).
The robot can only move either down or right at any point in time. The robot is trying-to-reach the bottom-right corner of the grid (marked ' Finish ' in the diagram below).
How many possible unique paths is there?
Above is a 3 x 7 grid. How many possible unique paths is there?
Note: m and N would be is at most 100.
Recursive timeout, using dynamic programming.
For lattice points (i,j). Because only the last grid point (I-1,J) or the left lattice point (I,j-1) is reached, and both paths are not duplicated
So count[i][j] = count[i-1][j]+count[i][j-1]
classSolution { Public: intUniquepaths (intMintN) {if(m==0|| n = =0) return 0; Else{vector<vector<int> > Count (M, vector<int> (n,1)); for(inti =1; I < m; i + +) { for(intj =1; J < N; J + +) {Count[i][j]= count[i][j-1]+count[i-1][j]; } } returncount[m-1][n-1]; } }};
"Leetcode" Unique Paths