← Uber Interview Insights

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

Intermediate
Jun 2026

Summary

Uber SWE online assessment, two coding problems back to back. The first was a graph/DP hybrid and the second was an optimization problem with a budget constraint. Nothing behavioral, just pure problem solving under time pressure.

Questions Asked (2)

Q1

Given an integer array of scores and an integer k, starting at index 0 and accumulating score[0], you can jump from index i to index j only if j > i, the gap is at most k, and the gap is a prime number. Find the maximum total score to reach the last index, or return null if it's unreachable. Scores can be negative.

Algorithms & Data Structures
Author's notes

The prime constraint is what makes this annoying.

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 score to reach index i. Precompute all prime gaps up to k, then for each index i, consider all previous indices j such that i-j is a prime gap and update dp[i] = max(dp[i], dp[j] + score[i]). Return dp[n-1] if reachable, else null.

Pro tip: Clarify edge cases upfront: what if k < 2 (no prime gaps), or if the array has only one element? Also, mention that negative scores mean you might need to skip certain jumps, so DP is necessary rather than greedy.

1. Understand the problem and constraints

Restate the rules: jumps only forward, gap ≤ k, gap must be prime. Note that scores can be negative, so maximizing total score may involve avoiding certain indices.

2. Precompute prime gaps

Generate all prime numbers up to k using a sieve or simple primality check. These are the only allowed jump distances.

3. Define DP state and recurrence

Let dp[i] be the max score to reach index i. Initialize dp[0] = score[0], others as -infinity. For each i, for each prime p ≤ k, if i-p ≥ 0 and dp[i-p] is reachable, update dp[i] = max(dp[i], dp[i-p] + score[i]).

4. Handle unreachable and return result

After filling dp, if dp[n-1] is still -infinity, return null; otherwise return dp[n-1]. Discuss time complexity O(n * number of primes ≤ k) and space O(n).

Key Points to Mention

  • Dynamic programming approach with state dp[i] = max score to reach index i.
  • Precomputing primes up to k to avoid repeated primality checks.
  • Handling negative scores: DP ensures we consider all valid paths, not just greedy jumps.
  • Edge cases: k < 2 (no primes), single-element array, unreachable last index.
  • Time and space complexity analysis: O(n * π(k)) time, O(n) space, where π(k) is number of primes ≤ k.
  • Potential optimization: iterate over primes instead of all previous indices to reduce checks.

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

Q2

You have a pipeline of n services where the bottleneck (minimum throughput) determines overall throughput. Each service can be expanded any number of times at a per-expansion cost, multiplying its throughput. Given a fixed budget, maximize the pipeline's throughput.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Binary search on the answer felt right and I went with it.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as maximizing the minimum throughput after allocating expansions under a budget. Use binary search on the target throughput T, and for each T compute the minimum cost to make every service's throughput ≥ T. If the total cost ≤ budget, T is feasible; otherwise, it's not.

Pro tip: Clarify whether expansions are discrete (integer number) or continuous, and whether throughputs and costs are integers. This affects the feasibility check and binary search bounds. Also, mention that if expansions are discrete, the cost function is a step function, but binary search still works if you compute the exact number of expansions needed.

1. Understand the problem and constraints

Restate the problem: we have n services in series, each with initial throughput t_i and expansion multiplier m_i (or additive increase) and cost c_i per expansion. We need to allocate expansions to maximize the minimum throughput under a budget B. Clarify if expansions are integer or continuous, and if throughputs are integers.

2. Formulate the feasibility check for a target throughput

For a given target T, compute the minimum cost to raise each service's throughput to at least T. If expansions multiply throughput by m_i, the required expansions for service i is the smallest integer k such that t_i * (m_i)^k ≥ T. The cost is k * c_i. Sum over all services.

3. Use binary search to find the maximum feasible T

Binary search on T between the initial minimum throughput and an upper bound (e.g., max initial throughput * (max multiplier)^(B/min_cost)). For each mid, check if total cost ≤ B. Adjust bounds accordingly.

4. Analyze complexity and edge cases

The binary search takes O(log(range)) iterations, each costing O(n) to compute the total cost. Discuss edge cases: budget insufficient for any expansion, very large multipliers, and the possibility of not expanding some services.

5. Discuss alternative approaches and trade-offs

Mention that a greedy approach (repeatedly expand the current bottleneck) may not be optimal because expanding a non-bottleneck could become beneficial later. Binary search is efficient and optimal for this problem. Also, consider if the problem can be solved with dynamic programming for small n and B.

Key Points to Mention

  • The bottleneck determines overall throughput, so we need to maximize the minimum throughput across all services.
  • Binary search on the answer (target throughput) is a common pattern for optimization problems with a monotonic feasibility condition.
  • For each service, compute the minimum number of expansions needed to reach the target throughput, considering the expansion multiplier (or additive increase).
  • The total cost for a target throughput is the sum of individual costs; compare with the budget to decide feasibility.
  • Time complexity: O(n log(max_throughput)) if expansions are continuous or if we can compute the required expansions in O(1) per service.
  • Edge cases: budget too small to expand any service, target throughput below initial minimum, and services with very high expansion costs.

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