|
3 | 3 | importjava.util.LinkedList; |
4 | 4 | importjava.util.Queue; |
5 | 5 |
|
6 | | -/** |
7 | | - * 1219. Path with Maximum Gold |
8 | | - * |
9 | | - * In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. |
10 | | - * Return the maximum amount of gold you can collect under the conditions: |
11 | | - * Every time you are located in a cell you will collect all the gold in that cell. |
12 | | - * From your position you can walk one step to the left, right, up or down. |
13 | | - * You can't visit the same cell more than once. |
14 | | - * Never visit a cell with 0 gold. |
15 | | - * You can start and stop collecting gold from any position in the grid that has some gold. |
16 | | - * |
17 | | - * Example 1: |
18 | | - * Input: grid = [[0,6,0],[5,8,7],[0,9,0]] |
19 | | - * Output: 24 |
20 | | - * Explanation: |
21 | | - * [[0,6,0], |
22 | | - * [5,8,7], |
23 | | - * [0,9,0]] |
24 | | - * Path to get the maximum gold, 9 -> 8 -> 7. |
25 | | - * |
26 | | - * Example 2: |
27 | | - * Input: grid = [[1,0,7],[2,0,6],[3,4,5],[0,3,0],[9,0,20]] |
28 | | - * Output: 28 |
29 | | - * Explanation: |
30 | | - * [[1,0,7], |
31 | | - * [2,0,6], |
32 | | - * [3,4,5], |
33 | | - * [0,3,0], |
34 | | - * [9,0,20]] |
35 | | - * Path to get the maximum gold, 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7. |
36 | | - * |
37 | | - * Constraints: |
38 | | - * 1 <= grid.length, grid[i].length <= 15 |
39 | | - * 0 <= grid[i][j] <= 100 |
40 | | - * There are at most 25 cells containing gold. |
41 | | - * */ |
42 | 6 | publicclass_1219 { |
43 | 7 | publicstaticclassSolution1 { |
44 | 8 | publicintgetMaximumGold(int[][]grid) { |
|