Problem Brief
Jump Game with Prime-Step Rule
FULLTIMEOA
See Uber online assessment and hiring insightsYou are given an integer array nums. You start at index 0 and want to reach index n - 1.
From index i, you may jump to any later index j if the step length j - i is prime and j - i <= nums[i].
Return 1 if the last index is reachable, otherwise return 0.
Function Description
Complete the function canReachWithPrimeSteps in the editor below.
canReachWithPrimeSteps has the following parameter:
int[] nums: the maximum jump lengths
Returns
int: 1 if the end is reachable, otherwise 0.
1Example 1
Input
nums = [2, 3, 1, 1, 0]
Output
1
Explanation
Jump from index 0 to 2 using prime step length 2, then from 2 to 4.
2Example 2
Input
nums = [1, 1, 1, 1]
Output
0
Explanation
Every allowed jump length is at most 1, and 1 is not prime.
Constraints
Limits and guarantees your solution can rely on.
1 <= nums.length <= 2 * 10^50 <= nums[i] <= 10^9