Tap here to switch tabs
Problem
Submissions

Problem: Path with Maximum Gold

Try to solve the Path with Maximum Gold problem.

Statement

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 00 gold.

  • 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

  • 1≤1 \leq m, n ≤15\leq 15

  • 0≤0 \leq grid[i][j] ≤100\leq 100

  • At most 2525 cells contain gold.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Path with Maximum Gold

Try to solve the Path with Maximum Gold problem.

Statement

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 00 gold.

  • 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

  • 1≤1 \leq m, n ≤15\leq 15

  • 0≤0 \leq grid[i][j] ≤100\leq 100

  • At most 2525 cells contain gold.