Learn
Practice
Newsletter
Resources
Mobile
New
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Jump Game II
Bookmark
Input
Example 1
With zero
All ones
Single element
Large first jump
Increasing
Custom
nums
=
[2, 3, 1, 1, 4]
0
1
2
3
4
goal
2
3
1
1
4
0
1
2
3
4
goal
2
3
1
1
4
jumps =
0
farthest =
0
0
1
2
3
4
farthest
goal
start
2
3
1
1
4
jumps =
0
, curr_end =
0
, farthest =
0
jumps =
0
farthest =
2
0
1
2
3
4
farthest
goal
start
2
3
1
1
4
i
farthest = max(
0
,
0 + 2
) =
2
jumps =
1
farthest =
2
0
1
2
3
4
farthest
goal
jump 1
2
3
1
1
4
i
i
0
==
curr_end
0
→
jump #1
, curr_end =
2
jumps =
1
farthest =
4
0
1
2
3
4
farthest
jump 1
2
3
1
1
4
i
farthest = max(
2
,
1 + 3
) =
4
jumps =
1
farthest =
4
0
1
2
3
4
farthest
jump 1
2
3
1
1
4
i
farthest = max(
4
,
2 + 1
) =
4
→ unchanged
jumps =
2
farthest =
4
0
1
2
3
4
farthest
jump 2
2
3
1
1
4
i
i
2
==
curr_end
2
→
jump #2
, curr_end =
4
jumps =
2
farthest =
4
0
1
2
3
4
farthest
jump 2
2
3
1
1
4
i
farthest = max(
4
,
3 + 1
) =
4
→ unchanged
jumps =
2
farthest =
4
0
1
2
3
4
2
3
1
1
4
1
2
Minimum jumps =
2
algo
master
.
io
Step:
Start: Find minimum jumps to reach the last index
0 / 8
Input
Example 1
With zero
All ones
Single element
Large first jump
Increasing
Custom
nums
=
[2, 3, 1, 1, 4]
0 / 8
algo
master
.
io
Step:
Start: Find minimum jumps to reach the last index