Jump Game with Prime-3 Steps
Updated
Problem statement
You are given an integer array arr. You start at index 0, and the score at the starting index is already included in your total.
From an index i, you may move only to the right. In one move, you can jump to either i + 1 or i + p, where p is a prime number whose last digit is 3, such as 3, 13, 23, 43, or 53. Composite numbers such as 33, 63, and 93 are not valid jump lengths.
Every jump must stay inside the array. You must finish exactly at index arr.length - 1. Return the maximum possible sum of the values at every index you land on, including both the start and the end.
Function
maxJumpScore(arr: int[]) → intExamples
Example 1
arr = [5, -100, 4, 10]return = 15Jump from index 0 to index 3 using a valid 3-step jump. The total is 5 + 10 = 15.
Example 2
arr = [4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20]return = 24Jump directly from index 0 to index 13. The jump length 13 is prime and ends in 3, so the total is 4 + 20 = 24.
Example 3
arr = [7]return = 7The starting index is already the last index.
Constraints
1 <= arr.length <= 100000-10000 <= arr[i] <= 10000- The start and end indices are always included in the score.
- A valid prime-3 jump length must be prime and must have units digit
3.
More Uber Online Assessment questions
- Count Palindromic Ancestor PathsOA · Seen Aug 2026
- Last Truck to Leave the LaneOA · Seen Jul 2026
- Chain of CommandOA · Seen Jul 2026
- Total Palindrome Substring CostOA · Seen Jun 2026
- Jump Game with Prime-Step RuleOA · Seen May 2026
- Pipeline Throughput Maximization Under BudgetOA · Seen May 2026
- Balanced Prefix Sets in a PermutationOA · Seen Apr 2026
- Minimum Edge Reversals to Root a TreeOA · Seen Apr 2026
- Maximum Riders in CarOA · Seen Apr 2026
- Graph Palindrome QueriesOA · Seen Apr 2026
Similar questions at other companies
- Count Permutations Without Three Equal Parities in a RowGoogle · OAGoogle interview questions
- Maximum Score with Prime JumpsMicrosoft · OAMicrosoft interview questions
- Jump Game with Prime-3 StepsAgoda · OAAgoda interview questions
- Coin Game From The EndsTekion · PHONE SCREENTekion interview questions
- Maximum-Product Subarray with an Empty ChoiceAkuna Capital · PHONE SCREENAkuna Capital interview questions
- Pascal's TriangleJP Morgan Chase · ONSITE INTERVIEWJP Morgan Chase interview questions
- Split Array to Minimize the Largest SumInfosys · OAInfosys interview questions
- Largest Consistent Visiting GroupAuxoAI · OA
- Delete and Freeze GameRubrik · OARubrik interview questions
- Lock CodeVisa · OAVisa interview questions