Uber Coding & Algorithms Interview Questions
Practice the exact questions companies are asking right now.
Find cheapest flight with at most K stops
Problem You are given a directed weighted graph representing flights between cities. Inputs - An integer n: number of cities, labeled 0..n-1. - A list...
Choose K pickup locations minimizing L1 distance
Coding: K Shuttle Pickup Locations (L1) You are given the coordinates of N people on a 2D grid. You want to open K shuttle pickup locations (pickup po...
Compute minimal time to finish dependent tasks
Coding: Task Scheduling With Prerequisites (Parallel Allowed) You have n tasks labeled 1..n. Each task takes exactly 1 unit of time to complete. Some ...
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...
Compute exclusive execution time from logs
Problem You are given execution logs from a single-threaded CPU that runs n functions labeled 0..n-1. The CPU can run only one function at a time. A f...
Maximize stock profit with one or two trades
You are given an array prices where prices[i] is the price of a given stock on day i (0-indexed). You want to maximize your profit by choosing when to...
Check feasibility of AI course schedule
You are designing a learning path for n AI-related courses, labeled from 0 to n - 1. Some courses have prerequisites. For example, to take course b, y...
Implement three interview-style coding tasks
You are given three separate coding tasks, all focused on algorithm and data-structure design. --- Task 1: Longest Bounded-Difference Subarray You are...
Compute outer boundary of an N-ary tree
You are given the root of a rooted N-ary tree. Each node contains: - An integer value. - An ordered list of children from left to right (0 or more chi...
Minimize time using elevator then climb stairs
Problem You need to go up n floors (from floor 0 to floor n). You may: 1. Take the elevator first (at most once, only at the start) for k floors, wher...
Print directory tree with indentation
You are given a root directory of a filesystem represented as a tree. Each node is either a directory (can have children) or a file (no children). Pri...
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...
Solve three algorithmic optimization and search problems
You are given three independent coding problems. --- Problem 1: Allocate tasks between two workers to maximize reward You have n independent tasks tha...
Compute square root to 1 decimal
Problem Given a non-negative real number x, implement a function sqrt1dp(x) that returns \(\sqrt{x}\) rounded (or truncated—clarify with interviewer) ...
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 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...