Skip to content

Commit fed81a2

Browse files
refactor 656
1 parent 02a3df5 commit fed81a2

File tree

1 file changed

+0
-29
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+0
-29
lines changed

src/main/java/com/fishercoder/solutions/_656.java

-29
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,6 @@
44
import java.util.Arrays;
55
import java.util.List;
66

7-
/**
8-
* 656. Coin Path
9-
*
10-
* Given an array A (index starts at 1) consisting of N integers: A1, A2, ..., AN and an integer B.
11-
* The integer B denotes that from any place (suppose the index is i) in the array A,
12-
* you can jump to any one of the place in the array A indexed i+1, i+2, …, i+B if this place can be jumped to.
13-
* Also, if you step on the index i, you have to pay Ai coins. If Ai is -1, it means you can’t jump to the place indexed i in the array.
14-
* Now, you start from the place indexed 1 in the array A,
15-
* and your aim is to reach the place indexed N using the minimum coins.
16-
* You need to return the path of indexes (starting from 1 to N) in the array you should take to get to the place indexed N using minimum coins.
17-
* If there are multiple paths with the same cost, return the lexicographically smallest such path.
18-
* If it's not possible to reach the place indexed N then you need to return an empty array.
19-
20-
Example 1:
21-
Input: [1,2,4,-1,2], 2
22-
Output: [1,3,5]
23-
24-
Example 2:
25-
Input: [1,2,4,-1,2], 1
26-
Output: []
27-
28-
Note:
29-
Path Pa1, Pa2, ..., Pan is lexicographically smaller than Pb1, Pb2, ..., Pbm,
30-
if and only if at the first i where Pai and Pbi differ, Pai < Pbi; when no such i exists, then n < m.
31-
A1 >= 0. A2, ..., AN (if exist) will in the range of [-1, 100].
32-
Length of A is in the range of [1, 1000].
33-
B is in the range of [1, 100].
34-
*/
35-
367
public class _656 {
378
public static class Solution1 {
389

0 commit comments

Comments
 (0)