← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Uber SWE coding round, two algorithmic questions back to back. Both had a binary search / DP flavor which I wasn't fully warmed up for. Manageable but not easy.

Questions Asked (2)

Q1

You have an array of vaults, each holding some positive integer amount, and a fixed number of hours h. Each hour you can work on only one vault and remove at most k units from it. What is the minimum integer k that lets you empty all vaults within h hours? Walk through your algorithm and its time complexity.

Algorithms & Data Structures
Author's notes

Classic binary search on the answer, basically the same shape as the 'eating bananas' problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Recognize that the minimum k can be found using binary search on the answer, since feasibility is monotonic: if a given k works, any larger k also works. For a fixed k, compute the total hours needed by summing ceil(vault/k) for each vault, and check if it's ≤ h. Binary search k in the range [1, max(vault)] to find the smallest feasible k.

Pro tip: Clarify that k must be an integer and that each hour you can remove up to k units from a single vault, so you can't split an hour across vaults. Also, mention that if h is less than the number of vaults, it's impossible, so return -1 or handle appropriately.

1. Understand the problem and constraints

Restate the problem: given an array of positive integers and an integer h, find the minimum integer k such that all vaults can be emptied in at most h hours, where each hour you can remove at most k units from one vault. Note that k must be at least 1 and at most the maximum vault value.

2. Define feasibility check

For a given k, compute the total hours required: sum over all vaults of ceil(vault / k). If this sum is ≤ h, then k is feasible; otherwise, it's not.

3. Apply binary search

Since feasibility is monotonic (if k works, any larger k also works), binary search for the smallest feasible k in the range [1, max(vault)]. Initialize low=1, high=max(vault), and while low < high, compute mid and adjust based on feasibility.

4. Analyze time complexity

The feasibility check takes O(n) time, and binary search runs O(log(max(vault))) iterations, so overall time complexity is O(n log(max(vault))). Space complexity is O(1).

5. Handle edge cases

If h < number of vaults, it's impossible to empty all vaults because each vault requires at least one hour, so return -1 or indicate impossibility. Also, ensure integer division and ceiling are handled correctly.

Key Points to Mention

  • Binary search on the answer (k) due to monotonic feasibility.
  • Feasibility check: sum of ceil(vault/k) ≤ h.
  • Time complexity: O(n log(max(vault))).
  • Space complexity: O(1).
  • Edge case: if h < n, return -1 (impossible).
  • Use integer arithmetic to avoid floating-point errors when computing ceiling.

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

Q2

Given a set of distinct positive integers and a target value, can you determine whether any subset sums exactly to the target? Describe the algorithm, its complexity, and how you'd reconstruct an actual valid subset if one exists.

Algorithms & Data Structures
Author's notes

DP table, O(n * target) time and space, pretty textbook.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints (e.g., number of integers, target size) to choose between dynamic programming and meet-in-the-middle. Then present a DP solution using a boolean table or bitset, and explain how to reconstruct the subset by backtracking through the DP table. Finally, discuss time and space complexity, and mention optimizations like bitset or pruning.

Pro tip: Mention that if the target is large but the number of elements is small (≤40), meet-in-the-middle is more efficient; this shows you consider trade-offs. Also, emphasize that reconstruction requires storing parent pointers or using a 2D DP table, and discuss how to handle memory constraints.

1. Clarify constraints and edge cases

Ask about input size, target range, and whether negative numbers or zeros are allowed. This determines the best algorithm and avoids over-engineering.

2. Choose an algorithm

For small n and target, use DP with a boolean table; for large target but small n, use meet-in-the-middle. Explain the trade-offs.

3. Describe the DP approach

Define dp[i][s] = true if a subset of first i elements sums to s. Transition: dp[i][s] = dp[i-1][s] or dp[i-1][s - nums[i]]. Base case dp[0][0] = true.

4. Explain reconstruction

If dp[n][target] is true, backtrack from (n, target): if dp[i-1][target] is true, skip element i; else include it and move to (i-1, target - nums[i]).

5. Analyze complexity and optimizations

Time O(n * target), space O(n * target) or O(target) with bitset. Mention meet-in-the-middle O(2^(n/2)) time and space, and pruning techniques.

Key Points to Mention

  • Dynamic programming with states (index, sum) and boolean values.
  • Reconstruction using parent pointers or backtracking through the DP table.
  • Time and space complexity: O(n * target) for DP, O(2^(n/2)) for meet-in-the-middle.
  • Space optimization using a 1D array or bitset for the boolean DP.
  • Handling large targets with meet-in-the-middle when n is small (≤40).
  • Edge cases: empty subset (target=0), no solution, and duplicate values (though problem says distinct).

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