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.
Subscribe to see which companies asked this question
1 Public classSolution {2 Public intUniquepaths (intMintN) {3 int[] ans =New int[m][n];4 for(inti = 0; i< m;i++){5Ans[i][0] = 1;6 }7 for(inti = 0; i< n;i++){8Ans[0][i] = 1;9 }Ten for(inti = 1;i < m; i++){ One for(intj = 1; j< N; J + +){ AANS[I][J] = ans[i][j-1] + ans[i-1][j]; - } - } the returnAns[m-1][n-1]; - } -}
Local is the most simple DP, the value of learning and understanding.
Paths-Unique Java Solutions