Given a two dimensional grid grid of size m by n, where each cell contains an integer representing the amount of gold in that cell, return the maximum amount of gold you can collect under the following conditions:
Every time you are located in a cell, you collect all the gold present in that cell.
From your current position, you can move one step up, down, left, or right.
You cannot visit any cell with
You cannot visit the same cell more than once in a single path.
You may start and stop collecting gold from any cell containing gold in the grid.
Constraints:
m == grid.length
n == grid[i].length
m, n
grid[i][j]
At most
Given a two dimensional grid grid of size m by n, where each cell contains an integer representing the amount of gold in that cell, return the maximum amount of gold you can collect under the following conditions:
Every time you are located in a cell, you collect all the gold present in that cell.
From your current position, you can move one step up, down, left, or right.
You cannot visit any cell with
You cannot visit the same cell more than once in a single path.
You may start and stop collecting gold from any cell containing gold in the grid.
Constraints:
m == grid.length
n == grid[i].length
m, n
grid[i][j]
At most