File tree 1 file changed +0
-51
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +0
-51
lines changed Original file line number Diff line number Diff line change 5
5
import java .util .PriorityQueue ;
6
6
import java .util .Queue ;
7
7
8
- /**
9
- * 675. Cut Off Trees for Golf Event
10
- *
11
- * You are asked to cut off trees in a forest for a golf event.
12
- * The forest is represented as a non-negative 2D map, in this map:
13
- * 0 represents the obstacle can't be reached.
14
- * 1 represents the ground can be walked through.
15
- *
16
- * The place with number bigger than 1 represents a tree can be walked through,
17
- * and this positive number represents the tree's height.
18
- *
19
- * You are asked to cut off all the trees in this forest in the order of tree's height -
20
- * always cut off the tree with lowest height first.
21
- * And after cutting, the original place has the tree will become a grass (value 1).
22
- *
23
- * You will start from the point (0, 0) and you should output the minimum steps you need to walk to cut off all the trees.
24
- *
25
- * If you can't cut off all the trees, output -1 in that situation.
26
- * You are guaranteed that no two trees have the same height and there is at least one tree needs to be cut off.
27
- *
28
- * Example 1:
29
- * Input:
30
- * [
31
- * [1,2,3],
32
- * [0,0,4],
33
- * [7,6,5]
34
- * ]
35
- * Output: 6
36
- *
37
- * Example 2:
38
- * Input:
39
- * [
40
- * [1,2,3],
41
- * [0,0,0],
42
- * [7,6,5]
43
- * ]
44
- * Output: -1
45
- *
46
- * Example 3:
47
- * Input:
48
- * [
49
- * [2,3,4],
50
- * [0,0,5],
51
- * [8,7,6]
52
- * ]
53
- * Output: 6
54
- *
55
- * Explanation: You started from the point (0,0) and you can cut off the tree in (0,0) directly without walking.
56
- * Hint: size of the given matrix will not exceed 50x50.
57
- */
58
-
59
8
public class _675 {
60
9
public static class Solution1 {
61
10
public int cutOffTree (List <List <Integer >> forest ) {
You can’t perform that action at this time.
0 commit comments