← 返回 uber 的题目列表Prime-Step Jump Game (Reachability with Prime-Length Jumps)
类型:online_judge
Problem: Prime-Step Jump Game (Reachability with Prime-Length Jumps)
You are given an integer array nums and start at index 0.
From position i, you may jump forward at most nums[i] steps.
However, you may only take jumps whose length is a prime number. That is, if you jump from i to j (j > i), then d = j - i must be prime and d <= nums[i].
Determine whether there exists a sequence of jumps that reaches the last index n-1.
Input
Line 1: integer n
Line 2: n integers nums[i]
Output
Print true or false.
Constraints
1 <= n <= 2 * 10^5
0 <= nums[i] <= 2 * 10^5
Notes
Because the original post only mentioned “Jump game, step count is primes”, the exact statement may differ; this version captures the typical OA-style interpretation.
Example
Input
1
0
Output
true