原题题目
代码实现(首刷自解)
int minimumTotal(int** triangle, int triangleSize, int* triangleColSize){
int y = triangleSize,x = triangleColSize[0],i,j,min = INT_MAX;
for(i=0;i<y;i++)
{
for(j=0;j<triangleColSize[i];j++)
{
if(!i)
triangle[i][j] = triangle[i][j];
else if(!j)
triangle[i][j] = triangle[i-1][j] + triangle[i][j];
else if(i == j)
triangle[i][j] = triangle[i-1][j-1] + triangle[i][j];
else
triangle[i][j] = fmin(triangle[i-1][j-1],triangle[i-1][j]) + triangle[i][j];
if(i == y-1)
{
if(triangle[i][j] < min)
min = triangle[i][j];
}
}
}
return min;
}