hi，bellow is my python code, which was judge for 'wrong answer' by system while work fine on my dev PC.

```
class Solution:
# @param grid, a list of lists of integers
# @return an integer
def minPathSum(self, grid):
if not grid or len(grid) == 0 or len(grid[0]) == 0:
return 0
m, n = len(grid), len(grid[0])
return minSum(grid, m - 1, n - 1)
cache = {}
def minSum(grid_data, m, n):
# cache the result
key = '%d_%d' % (m, n)
if key in cache:
return cache[key]
#print key
val = 0
if m == 0 and n == 0:
val = grid_data[0][0]
elif m == 0:
val = minSum(grid_data, m, n - 1) + grid_data[m][n]
elif n == 0:
val = minSum(grid_data, m - 1, n) + grid_data[m][n]
else:
val = min(minSum(grid_data, m - 1, n), minSum(grid_data, m, n - 1)) + grid_data[m][n]
cache[key] = val
return val
```

After I change the `minSum`

fucntion to class function like this submission, I got a accept. So I wonder if the global function is not allowed in the answer?