@@ -0,0 +1,1241 @@
+package com.fulin.DP;%0A%0Aimport java.util.Arrays;%0A%0A/**%0A * Given a m x n grid filled with non-negative numbers, find a path from top%0A * left to bottom right which minimizes the sum of all numbers along its path.%0A * Note: You can only move either down or right at any point in time.%0A *%0A * Created by fulin on 17-7-31.%0A */%0Apublic class MinPathSum %7B%0A%0A    public static void main(String%5B%5D args)%7B%0A        int%5B%5D%5B%5D grid = %7B%7B3,4,6%7D,%7B2,6,4%7D,%7B1,3,1%7D%7D;%0A        int result = minPathSum(grid);%0A        System.out.println(result);%0A    %7D%0A%0A    public static int minPathSum(int%5B%5D%5B%5D grid) %7B%0A        if(grid == null)%7B%0A            return 0;%0A        %7D%0A%0A        int m = grid.length;%0A        int n = grid%5B0%5D.length;%0A%0A        int%5B%5D%5B%5D path = new int%5Bm%5D%5Bn%5D;%0A%0A%0A        for(int i=0 ; i%3C m ;i ++)%7B%0A            System.arraycopy(grid%5Bi%5D,0,path%5Bi%5D,0,n);%0A        %7D%0A%0A        for(int i = 1 ; i%3Cn ; i++)%7B%0A            path%5B0%5D%5Bi%5D = path%5B0%5D%5Bi%5D + path%5B0%5D%5Bi-1%5D;%0A        %7D%0A%0A        for(int i = 1; i %3C m ; i++)%7B%0A            path%5Bi%5D%5B0%5D  = path%5Bi%5D%5B0%5D + path%5Bi-1%5D%5B0%5D;%0A        %7D%0A%0A        for(int i=1;i%3Cm;i++)%7B%0A            for (int j = 1;j%3Cn;j++)%7B%0A                path%5Bi%5D%5Bj%5D = Math.min(path%5Bi - 1%5D%5Bj%5D,path%5Bi%5D%5Bj-1%5D) + path%5Bi%5D%5Bj%5D;%0A            %7D%0A        %7D%0A        return path%5Bm-1%5D%5Bn-1%5D;%0A    %7D%0A%7D%0A

leetcode : 64. Minimum Path Sum