Dashboard
LC #45

Jump Game II

Pattern · ?AmazonGoogleMetaBloomberg

Problem

Find the minimum number of jumps to reach the last index (you are guaranteed to reach it).

Constraints

  • 1 ≤ nums.length ≤ 10⁴
  • 0 ≤ nums[i] ≤ 1000
  • Always possible to reach last index

Example

Input
nums = [2, 3, 1, 1, 4]
Output
2
Why
Minimum 2 jumps: index 0 → index 1 → index 4

Spot the pattern

Which pattern cracks it?

Hints

One at a time
Solve on LeetCode ↗