GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Leetcode-Algorithms/src/leetcode/MinimumPathSum.java at master · edyluisrey/Leetcode-Algorithms Expand file tree/ Copy pathMinimumPathSum.javaMore file actions 23 lines (21 loc) · 670 Bytes / Copy pathMinimumPathSum.javaFile metadata and controls23 lines (21 loc) · 670 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 package leetcode; public class MinimumPathSum { public int minPathSum(int[][] grid) { if(grid==null || grid.length==0) return 0; int n = grid.length; int m= grid[0].length; int[][] dp= new int[n][m]; dp[0][0]=grid[0][0]; for(int i=1; i<n; i++){ dp[i][0]= dp[i-1][0]+ grid[i][0]; } for(int j=1; j<m;j++){ dp[0][j]= dp[0][j-1]+ grid[0][j]; } for(int i = 1; i < n; i++){ for(int j = 1; j < m; j++){ dp[i][j] = Math.min(dp[i-1][j], dp[i][j-1]) + grid[i][j]; } } return dp[n-1][m-1]; } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |