File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -30,11 +30,12 @@ This is the solutions collection of my LeetCode submissions, most of them are pr
30
30
| 34| [ Search for a Range] ( https://leetcode.com/problems/search-for-a-range/ ) | [ JavaScript] ( ./src/search-for-a-range/res.js ) | Medium|
31
31
| 41| [ First Missing Positive] ( https://leetcode.com/problems/first-missing-positive/description/ ) | [ JavaScript] ( ./src/first-missing-positive/res.js ) | Hard|
32
32
| 43| [ Multiply Strings] ( https://leetcode.com/problems/multiply-strings/ ) | [ JavaScript] ( ./src/multiply-strings/res.js ) | Medium|
33
+ | 45| [ Jump Game II] ( https://leetcode.com/problems/jump-game-ii/ ) | [ JavaScript] ( ./src/jump-game-ii/res.js ) | Hard|
33
34
| 46| [ Permutations] ( https://leetcode.com/problems/permutations/ ) | [ JavaScript] ( ./src/permutations/res.js ) | Medium|
34
35
| 48| [ Rotate Image] ( https://leetcode.com/problems/rotate-image/ ) | [ JavaScript] ( ./src/rotate-image/res.js ) | Medium|
35
36
| 49| [ Group Anagrams] ( https://leetcode.com/problems/anagrams/ ) | [ JavaScript] ( ./src/anagrams/res.js ) | Medium|
36
37
| 54| [ Spiral Matrix] ( https://leetcode.com/problems/spiral-matrix/ ) | [ JavaScript] ( ./src/spiral-matrix/res.js ) | Medium|
37
- | 55| [ Jump Game] ( https://leetcode.com/problems/jump-game/ ) | [ JavaScript] ( ./src/jump-game/res.js ) | Medium|
38
+ | 55| [ Jump Game] ( https://leetcode.com/problems/jump-game/ ) < sup > * </ sup > | [ JavaScript] ( ./src/jump-game/res.js ) | Medium|
38
39
| 66| [ Plus One] ( https://leetcode.com/problems/plus-one/ ) | [ JavaScript] ( ./src/plus-one/res.js ) | Easy|
39
40
| 69| [ Sqrt(x)] ( https://leetcode.com/problems/sqrtx/ ) | [ JavaScript] ( ./src/sqrtx/res.js ) | Easy|
40
41
| 71| [ Simplify Path] ( https://leetcode.com/problems/simplify-path/ ) | [ JavaScript] ( ./src/simplify-path/res.js ) | Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number[] } nums
3
+ * @return {number }
4
+ */
5
+ var jump = function ( nums ) {
6
+ const len = nums . length ;
7
+ let end = 0 ;
8
+ let step = 0 ;
9
+ let furthestStep = 0 ;
10
+
11
+ for ( let index = 0 ; index < len - 1 ; index ++ ) {
12
+ const element = nums [ index ] ;
13
+ furthestStep = Math . max ( furthestStep , index + element ) ;
14
+
15
+ if ( index === end ) {
16
+ end = furthestStep ;
17
+ step ++ ;
18
+ }
19
+ }
20
+
21
+ return step ;
22
+ } ;
You can’t perform that action at this time.
0 commit comments