Uber Software Engineer 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...
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...
Implement 2D word search variants and analyze complexity
Given an m x n grid of uppercase letters board and a string word, implement two related functions: ( 1) Fixed-direction search: Return true if word ap...
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...
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...
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...
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 next and closest palindromes
Given a non-negative integer represented as a string n (no leading zeros unless n == "0"), return the smallest palindromic integer strictly greater th...
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...
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...
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 ...
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...
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...
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...
Produce a valid deployment order
You are given N services and a list of dependency pairs (A, B) meaning service B must be deployed before service A. Compute any valid deployment order...
Perform matrix Candy Crush elimination
Question Implement a function that, given an m × n integer matrix representing colored blocks (same integers = same color), performs one round of "Can...
Implement rate limiter, top-K, scheduler algorithms
Question Design and implement a thread-safe Rate Limiter; extend it to support multi-threading and a version where current time is not passed as an ar...
Find minimal rate k and subset sum
Question LeetCode 875. Koko Eating Bananas — Given vault sizes [3, 6, 7, 11] and time h = 8 hours, find the minimum integer rate k (vault units per ho...
Handle invalid Lisp expression parsing
Question LeetCode 736. Parse Lisp Expression – Given a string representing a Lisp-like expression containing let/add/mult operations and variable bind...