← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jul 2026

Summary

Uber coding round for a Software Engineer role, one problem the whole session, a Jump Game variant that looked familiar until it wasn't.

Questions Asked (1)

Q1

You start at index 0 of an array of length n. At each step you can either move exactly 1 position forward, or jump forward by a prime number that ends in the digit 3 (like 3, 13, 23, 43, and so on). Using dynamic programming, determine whether the last index is reachable and find the minimum number of jumps to get there.

Algorithms & Data Structures
Author's notes

I recognized Jump Game pretty fast and started talking through a standard BFS/DP approach.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the problem constraints and define the allowed moves. Then, design a dynamic programming solution where dp[i] represents the minimum jumps to reach index i, initializing dp[0]=0 and others to infinity. Iterate through indices, and for each, update reachable positions by moving +1 or jumping by valid primes ending in 3, ensuring to precompute or generate such primes up to n.

Pro tip: Mention that you can precompute all valid prime jumps up to n using a sieve, and note that the +1 move ensures all indices are reachable, so the problem reduces to finding the minimum jumps efficiently.

1. Clarify and Define

Confirm the rules: start at index 0, moves are +1 or +p where p is prime and ends in 3. Ask if n can be 0 or 1, and if the last index is n-1.

2. Precompute Valid Jumps

Generate all primes up to n that end in digit 3. Use a sieve of Eratosthenes for efficiency, then filter primes ending in 3.

3. DP State and Transition

Define dp[i] as min jumps to reach i. Initialize dp[0]=0, others infinity. For each i from 0 to n-1, if dp[i] is finite, update dp[i+1] and dp[i+p] for each valid prime p.

4. Compute and Return

After filling dp, check dp[n-1]. If finite, return it; else, return -1 (though +1 move makes it always reachable).

5. Analyze Complexity

Time: O(n * number of valid primes) which is roughly O(n^2 / log n) worst-case, but can be optimized. Space: O(n) for dp and primes.

Key Points to Mention

  • Dynamic programming state definition and initialization
  • Precomputing primes ending in 3 using sieve
  • Transition using both +1 and prime jumps
  • Handling unreachable cases (though +1 ensures reachability)
  • Time and space complexity analysis
  • Potential optimization: using BFS instead of DP for minimum jumps

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.