Uber's DSA rounds lean on dynamic programming, graphs, and shortest-path patterns — and interviewers regularly change the constraints mid-round with a live follow-up, so being able to adapt an already-working solution matters as much as solving it the first time. The three problems below are real, recently reported (2025) Uber questions with full solutions.
Given a set of keys with associated access weights, build a binary search tree over them that minimizes the total weighted search cost — a variation of the classic Optimal Binary Search Tree problem, with an extra constraint layered on top by the interviewer.
Input: keys = [10, 20, 30], weights = [3, 2, 5]
Output: A tree arrangement (e.g. 30 as root) minimizing total weighted depth-cost
The exact extra constraint the interviewer adds on top of the base OBST formulation varies by report; clarify it explicitly before coding.
Two players alternately pick a value from either end of a row of numbers, each trying to maximize their own total under optimal play from both sides — a variant of the classic 'Optimal Strategy for a Game' problem, with the interviewer changing how corner values are chosen.
Input: a = [5, 3, 7, 10]
Output: 15
The first player can guarantee 15 by picking 10, then 7, under optimal play from both sides.
Given a weighted graph and several designated source nodes, find the shortest distance from the nearest source to every other node, with a follow-up on optimizing the approach for very large graphs.
Input: n = 5, edges (weighted, undirected), sources = [0, 3]
Output: distance array of length 5
Each node's answer is its distance to whichever source reaches it first.

