← Uber Interview Insights

Uber·Software Engineer·Online Assessment (OA)·Intermediate

IntermediatePrefer not to say
May 2026Remote

Summary

Uber's Hack2Hire OA was a 90-minute two-problem set and the one I got tripped up on was a Jump Game variant with a pretty specific twist on allowed step sizes. Not a brutal interview format but the hidden test cases are where people get burned.

Questions Asked (1)

Q1

Given an integer array, start at index 0 and reach the last index by jumping either +1 or +k steps where k is a prime number whose last digit is 3 (like 3, 13, 23, 43...). Maximize the sum of values at all landed indices.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

My first instinct was just brute force DP, loop over every valid jump from each position.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as a dynamic programming problem where dp[i] represents the maximum sum to reach index i. For each index, consider jumps of +1 and +k for all prime k ending in 3, and take the maximum. Optimize by precomputing valid k values and using efficient data structures if needed.

Pro tip: Clarify edge cases upfront (e.g., array length, negative values, unreachable indices) and discuss time/space complexity trade-offs, showing you think about scalability and real-world constraints.

1. Understand the problem and constraints

Restate the problem, confirm jump rules, and ask about array size, value ranges, and whether all indices must be reachable. Identify that k must be prime and end with digit 3.

2. Define DP state and recurrence

Let dp[i] be the maximum sum to reach index i. Initialize dp[0] = arr[0]. For i > 0, dp[i] = arr[i] + max(dp[i-1], max over valid k of dp[i-k] if i-k >= 0).

3. Precompute valid k values

Generate all primes ending in 3 up to n-1 using a sieve or trial division. Store them in a list for quick access during DP transitions.

4. Implement and optimize

Iterate i from 1 to n-1, compute dp[i] using the recurrence. If the number of valid k is large, consider optimizing by grouping or using a sliding window maximum, but analyze complexity first.

5. Analyze complexity and edge cases

Time complexity: O(n * P) where P is number of valid primes, or O(n log log n + n * P) with sieve. Space: O(n). Handle cases where no valid jump exists (dp[i] = -infinity) and negative values.

Key Points to Mention

  • Dynamic programming approach with state definition and recurrence relation
  • Precomputation of prime numbers ending in 3 using Sieve of Eratosthenes
  • Time and space complexity analysis, including trade-offs
  • Handling of negative values and unreachable indices
  • Optimization techniques if the number of valid primes is large (e.g., sliding window maximum)
  • Edge cases: array length 1, no valid jumps, large input size

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