medium 0 views
Minimum Jumps to Reach End via Prime Teleportation
You are given an integer array nums of length n.
You are given an integer array nums of length n.
You start at index 0, and your goal is to reach index n - 1.
From any index i, you may perform one of the following operations:
Return the minimum number of jumps required to reach index n - 1.
Example 1
Input: nums = [1,2,4,6]
Output: 2
Explanation: One optimal sequence of jumps is: Thus, the answer is 2.
Example 2
Input: nums = [2,3,4,7,9]
Output: 2
Explanation: One optimal sequence of jumps is: Thus, the answer is 2.
Example 3
Input: nums = [4,6,5,8]
Output: 3
Constraints
- 1 <= n == nums.length <= 10^5
- 1 <= nums[i] <= 10^6
Hints
Companies
No companies reported yet.
Discussion
Sign in to join the discussion.
Loading discussion...
Test results
No test cases yet.