Beating 100.0% of pythonsubmission

  • 0
    class Solution(object):
        def minPathSum(self, grid):
            :type grid: List[List[int]]
            :rtype: int
            for row in xrange(1,len(grid)):
                grid[row][0] += grid[row-1][0]
            for col in xrange(1,len(grid[0])):
                grid[0][col] += grid[0][col-1]
            for i in xrange(1,len(grid)):
                for j in xrange(1,len(grid[0])):
                    grid[i][j] += min(grid[i-1][j],grid[i][j-1])  
            return grid[len(grid)-1][len(grid[0])-1]

    0_1473137956349_2016-09-06 12-51-00屏幕截图.png

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.