标签:write java log return min class div logs param
public class Solution { /* * @param triangle: a list of lists of integers * @return: An integer, minimum path sum */ public int minimumTotal(int[][] triangle) { // write your code here int [][]minResult=new int[triangle.length][triangle.length]; minResult[0][0]=triangle[0][0]; for(int i=1;i<triangle.length;i++) { for(int j=0;j<triangle[i].length;j++) { if(j==0) { minResult[i][j] = minResult[i-1][j]+triangle[i][j]; } else if( j==triangle[i].length-1) { minResult[i][j]=minResult[i-1][j-1]+triangle[i][j]; } else { minResult[i][j]=Math.min(minResult[i-1][j-1],minResult[i-1][j])+triangle[i][j]; } } } int min=minResult[triangle.length-1][0]; for(int i=1;i<minResult[triangle.length-1].length;i++) { if(min>minResult[triangle.length-1][i]) { min=minResult[triangle.length-1][i]; } } return min; } }
标签:write java log return min class div logs param
原文地址:http://www.cnblogs.com/temporary/p/7654707.html