My accepted java Solution


  • 0
    D
    public class Solution {
        public int uniquePaths(int m, int n) {
        int table[][] = new int[m][n];
        
        for(int i = 0; i < m;i++) {
            table[i][0] = 1;
        }
        for(int i = 1; i < n;i++) {
            table[0][i] = 1;
        }
        for(int row = 1; row < m;row++) {
            for(int column = 1; column < n;column++) {
                table[row][column] = table[row-1][column] + table[row][column - 1]; 
                
            }
        }
        return table[m-1][n-1];
        }
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.