题目:
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.
解答:class Solution {
public:
int minPathSum(vector<vector<int> > &grid) {
int m = grid.size();
int n = (m == 0 ? 0 : grid[0].size());
if(m == 0 || n == 0) {
return 0;
}