Leetcode 64. Minimum Path Sum

题目

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.

Note: You can only move either down or right at any point in time.

分析

给出一个非负整数的矩阵,找出从左上角到右下角数值之和最小的路径。
也是使用动态规划的思想,看从→和↓两个方向到达的路径哪条上的数值之和更小。
最后输出值即可。类似的:http://www.jianshu.com/p/717ccf2d69ee

int minPathSum(int** grid, int gridRowSize, int gridColSize) {
    int * ans=(int *)malloc(sizeof(int)*gridColSize);
    ans[0]=grid[0][0];
    for(int i=1;i

你可能感兴趣的:(Leetcode 64. Minimum Path Sum)