← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Uber SWE interview with a dynamic programming / greedy problem involving a jump game with unusual movement rules. The problem had a tricky constraint I hadn't seen before and I'm still not 100% sure I handled it optimally.

Questions Asked (1)

Q1

Given an integer array, start at index 0 and reach the last index to maximize your total score. From any position i you can move to i+1, or jump directly to any index whose value ends in 3 (like index 3, 13, 23, etc.). You must land exactly on the last cell. What's the maximum score you can collect?

Algorithms & Data Structures
Author's notes

The i+1 movement is obvious but the 'jump to any index ending in 3' rule threw me off at first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints (array size, score definition, jump rule) and then propose a dynamic programming solution. Define dp[i] as the maximum score to reach index i, and compute it using transitions from i-1 and from all indices j where j ends in 3 and j < i. Optimize by precomputing the best jump source among indices ending in 3.

Pro tip: Mention that you can maintain a running maximum of dp[j] for all j ending in 3 to achieve O(n) time, and discuss edge cases like when the last index is not reachable or when the array has only one element.

1. Clarify the problem

Ask about the definition of score (e.g., sum of values at visited indices, including start and end), constraints on array size and values, and whether jumps to indices ending in 3 are allowed only from certain positions or from any position.

2. Define state and recurrence

Let dp[i] be the maximum score to reach index i. Then dp[i] = value[i] + max(dp[i-1], max_{j < i, j ends in 3} dp[j]). Base case: dp[0] = value[0].

3. Optimize with running maximum

Maintain a variable best_jump that stores the maximum dp[j] for all j ending in 3 seen so far. Update it when i ends in 3, and use it for the jump transition.

4. Handle edge cases and complexity

Check if the last index is reachable (e.g., if n=1, answer is value[0]). Time complexity O(n), space O(1) if only dp[i-1] and best_jump are kept, or O(n) if full dp array is used.

5. Test with examples

Walk through a small example to verify the recurrence and edge cases, such as [1,2,3,4] where jumps to index 3 are allowed.

Key Points to Mention

  • Dynamic programming with state dp[i] representing max score to reach index i
  • Transition: dp[i] = value[i] + max(dp[i-1], best_jump) where best_jump is max dp[j] for j ending in 3 and j < i
  • Optimization: maintain best_jump variable to avoid O(n^2) time
  • Time complexity O(n), space complexity O(1) or O(n) depending on implementation
  • Edge cases: single element array, unreachable last index, negative values
  • Clarify whether the score includes the value at the starting index and the last index

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