Nice solution.

I rewrote it in python if anyone is interested:

class Solution(object):
def minPathSum(self, grid):
"""
:type grid: List[List[int]]
:rtype: int
"""
for y, R in enumerate(grid):
for x, _ in enumerate(R):
if (x,y) == (0,0): continue
if y is 0: grid[y][x] += grid[y][x-1]
elif x is 0: grid[y][x] += grid[y-1][x]
else: grid[y][x] += min(grid[y][x-1], grid[y-1][x])
return grid[-1][-1]