AO
Back

OA: Jump Game with Prime Steps Ending in 3

Also reported as Prime Jumps · Jump Game Prime · Jump Game VI (LeetCode 1696) Variant

OAAsync OALast reported August 2026High Frequency

Problem Overview

Where you'll code it
HackerRank
Live shared coding environment. You may need to create test files / inputs yourself.
Full problem statement

The round: one of the two problems in Uber's HackerRank online assessment (90 minutes, camera on in several reports). Eleven reports from November 2025 to August 2026 describe it, usually paired with a tree problem. Several reports call it a DP; one compares it to LeetCode 1696 (Jump Game VI) with a different jump rule. One write-up gives the full rules, an example and the constraint n ≤ 10^4. One graded part.

Problem

cell is a row of n integers and you start on cell 0. From cell i you may:

  1. step to cell i + 1, or
  2. jump to cell i + p, where p is a prime whose last digit is 3 (3, 13, 23, 43, 53, ...).

Each cell you land on adds its value to your score. You must finish exactly on the last cell, n - 1. Return the maximum score. In the reported version cell[0] = 0 and n ≤ 10^4.

def prime_jumps(cell: list[int], rule: str = "prime") -> int: ...

Example

cell = [0, -10, -20, -30, 50]
0 -> 3 -> 4   (jump 3, then step 1)   score -30 + 50 = 20
0 -> 1 -> 4   (step 1, then jump 3)   score -10 + 50 = 40
answer: 40

The jump rule is worded three ways. Clarify it first. Most reports say a jump is a prime ending in 3. One says any integer ending in 3, which adds lengths like 33 and 63. One says you may jump to any later index whose last digit is 3. The three rules give different answers on the same array, so rule selects one: "prime" (the default, the majority reading), "ends_in_3" or "index_ends_in_3". One test runs all three.

Notes: the function name, the rule parameter, raising ValueError on an empty array, and every example except the one above are ours. The reference counts cell[0] in the score; that only matters if cell[0] is not 0, and no test depends on it.

Approach Trade-offs

Approaches actually attempted in reports — including ones that lost candidates time. Pick deliberately.
ApproachNotes
Top-down memoised recursion gives the same On * P) work, but Python's recursion limit makes the iterative DP the safer choice at n = 10^4.

What Reports Emphasize

Common mistakes: Leaving out the step of 1; one report stresses that a move is a step of 1 or a prime ending in 3, and both belong in the transition.; Testing primality inside the DP instead of sieving the primes ending in 3 up to n once.; Reading the jump rule loosely: most reports say a prime jump length ending in 3, one says any length ending in 3, and one says a jump to an index ending in 3. The answers differ, so confirm which one your version uses.; Overshooting the last cell: the route must finish exactly on it.

What candidates did: One write-up sieved the primes ending in 3 up to n and used dp[i] = cell[i] + max(dp[i-1], dp[i-p]), and says that is fast enough for n up to 10^4.

What passers do: A replier on one report, who did not say which two problems they got, passed every test on the first problem and 10 of 15 on the second, and was told they passed the OA.

Edge cases to test: All negative values (you must still land on the last cell); n below 4, where no jump fits and only steps work; n near 10^4, where a per-step primality test is too slow.

Practice

Write your own against 8 test cases, or read the worked solution — approach, complexity, and code that runs.

Prepping for Uber with friends?

Send them this page. It is free to read, no account needed.

More Uber Questions

Free preview

Every question in the Uber catalog gets this depth

What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 83 Uber questions, refreshed monthly from new candidate reports.

$59/mo — or $50/mo with the 3-month pass · cancel anytime
Uber · OA · Reported 11× across candidate reports
Is this helpful?