SHARE
TWEET

Untitled

a guest Aug 21st, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Solution {
  2.     public int uniquePaths(int m, int n) {
  3.         int[][] dp = new int[m][n];
  4.        
  5.         for(int i = 0; i < n; i++) {
  6.             dp[0][i] = 1;
  7.         }
  8.         for(int i = 0; i < m; i++) {
  9.             dp[i][0] = 1;
  10.         }
  11.        
  12.         for (int i = 1; i < m; i++) {
  13.             for (int j = 1; j < n; j++) {
  14.                 dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
  15.             }
  16.         }
  17.        
  18.         return dp[m-1][n-1];
  19.     }
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top