### LeetCode 64. Minimum Path Sum 二維路線最短路徑

`#define INF 0x7ffffffclass Solution {int pathl[1000][1000];    public:    int minPathSum(vector<vector<int>>& grid) {        int m = grid.size(), n = grid[0].size();        int i,j,leftl ,upl;                for(i = 0;i < m;i++){            for(j = 0; j < n;j++){                if(i == 0 && j == 0){                    pathl[i][j] = grid[0][0];                    continue;                }                if(j != 0)                    leftl = pathl[i][j-1] + grid[i][j];                else leftl = INF;                if(i != 0)                    upl = pathl[i-1][j] + grid[i][j];                else upl = INF;                pathl[i][j] = leftl < upl?leftl : upl;            }        }        return pathl[m-1][n-1];    }};`

`class Solution {public:    int minPathSum(vector<vector<int>>& grid) {        int m = grid.size(), n = grid[0].size();        int i,j,leftl ,upl;        vector<int> pathl(n,0);  //每一列的當前最小值        pathl[0] = grid[0][0];        for(j = 1;j < n; j++)            pathl[j] = pathl[j-1] + grid[0][j];        for(i = 1;i < m; i++){            pathl[0] = pathl[0] + grid[i][0];            for(j = 1;j < n;j++)                pathl[j] = grid[i][j] + min(pathl[j-1],pathl[j]);        }           return pathl[n-1];    }};`