class Solution {

public:int PathHelper(vector<vector<int> > &grid,int x,int y,int sum) {

```
if(x>grid[0].size()-1 || y>grid.size()-1)
return INT_MAX;
sum+=grid[x][y];
if(x==grid[0].size()-1 && y==grid.size()-1)
return sum;
else
{
return min(PathHelper(grid,x+1,y,sum),PathHelper(grid,x,y+1,sum));
}
}
int minPathSum(vector<vector<int> > &grid) {
return PathHelper(grid,0,0,0);
}
```

};

I encounter vector subscript out of range problem but i can't figure out why it that.