Uber Coding & Algorithms Interview Questions
Master your tech interview with our curated database of real questions from top companies.
Detect cycle in directed dependency graph
You are given a directed dependency graph representing services in a system. - There are n services, labeled from 0 to n - 1. - You are given a list o...
Implement weighted sampling without replacement
Implement in Python a function sample_k(items, weights, k) that returns k items without replacement with probability proportional to weight. Requireme...
Design airport dispatch with ETA uncertainty
You control airport pickups with streaming ETAs for arriving flights and live driver locations/queues. Design an online dispatch algorithm that minimi...
Implement sqrt with Newton vs binary search
Implement numerically robust square-root routines and analyze convergence Task 1 — sqrt_newton(x, tol=1e-12) Implement a Python function that returns ...
Check anagrams under real-world constraints
Given two strings s and t, determine whether they contain exactly the same multiset of characters (e.g., 'abc' and 'cab' → true; 'aab' and 'ab' → fals...
Compute maximum concurrent trips from intervals
You’re given n trip intervals [start, end) in seconds, where start < end, representing when a rider’s trip starts and ends in a city on a specific day...
Design room progression with leaderboard
Design a data structure to simulate a sequence of rooms where players solve tasks and can move only to the next room once finished. Support the follow...
Simulate one-round color elimination on a grid
Given an m x n integer matrix board where board[r][c] > 0 represents a color and 0 represents empty: ( 1) A nonzero cell at (r,c) explodes in this rou...
Count subarrays with at least k fruit pairs
Given an integer array nums where each value denotes a fruit type, and an integer k: For any subarray, define a 'pair' for fruit value v if its freque...
Solve minimum rate and subset sum
1) Minimum rate to finish vaults within a deadline: You are given an array vaults of positive integers representing the amount in each vault along a r...
Count connected delivery zones
Given an m x n grid representing a service area, each cell is either 'Z' (deliverable zone) or '#' (blocked). Two 'Z' cells belong to the same zone if...
Compute build order from dependencies
Given a set of package build dependencies, output a valid build order so that each package is built only after all of its dependencies. The input is a...
Solve vault rate and subset-sum
1) Robber vaults rate: You are given an array vaults of positive integers where vaults[i] is the amount in the i-th vault, and an integer h (hours). I...
Find earliest common slot
Given calendars for N attendees, each as a sorted list of non-overlapping, closed-open intervals [start, end) in minutes since epoch, and a required m...
Implement binary search variants
Implement binary search on a sorted integer array without using library functions. Provide both iterative and recursive versions that: (a) return the ...
Design top-K frequency structure
Design an in-memory data structure that supports: add(x) to observe an item, inc(x) to increment its frequency, dec(x) to decrement (deleting when zer...
Simulate views on an n-ary tree
Given a rooted, ordered n-ary tree (each node has a value and an ordered list of children), simulate an observer who starts at the bottom-left, moves ...
Sort by squares and find k-th smallest
Given a nondecreasing sorted array of integers nums, do the following: 1) Reorder the original elements by increasing square value (equivalently, by a...
Simulate fixed-shape tiling on a grid
You are given an empty n-by-m grid and a list of tile patterns, patterns[0..k-1]. Each pattern is a binary matrix (1 = filled cell, 0 = hole) and must...
Find leftmost point of maximum brightness
You are given an array of lights, where each light is [p, r] representing a lamp centered at coordinate p on the real number line with radius r, illum...