Hello, the following is my code, I'm keep getting the time limit exceeded error, can anybody help?

```
function find(x,y){
if(x+1 <= maxX && y+1 <= maxY){
var down = find(x+1,y);
var left = find(x,y+1);
var sum = down <= left? down:left;
return mainGrid[x][y] + sum;
}
if(x+1 <= maxX){
return mainGrid[x][y] + find(x+1,y);
}
if(y+1 <= maxY){
return mainGrid[x][y] + find(x,y+1);
}
return mainGrid[x][y];
}
var mainGrid;
var maxX;
var maxY;
var minPathSum = function(grid) {
if(grid.length === 0){
return 0;
}
mainGrid = grid;
maxX = grid.length - 1;
maxY = grid[0].length - 1;
return find(0,0);
};
```