Java DP solution


  • 0
    S
    public int uniquePaths(int m, int n) {
        int[] dp = new int[n + 1];
            
        dp[n - 1] = 1;
        for (int i = m - 1; i >= 0; i--) {
            for (int j = n - 1; j >= 0; j--) {
                dp[j] += dp[j + 1];
            }
        }
            
        return dp[0];
    }
    

Log in to reply
 

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