Uber logo

Uber Hard Interview Questions

18 hard-level practice questions for Uber technical interviews

Uber software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer
11
Coding
1
System Design
coding Hard Verified Question #1

1. OA [CodeSignal] Adventure Levels


Category: Array coding problem

OA [CodeSignal] Adventure Levels You start with initial energy K. You need to clear a series of adventure levels. For each level i: -...

Input: Array
Output: Array
Want to practise this one?
Create a free account to open the full question and practise Uber questions with AI.
Sign up free
coding Hard Verified Question #2

2. OA [CodeSignal] Balanced Numbers in Permutation


Category: Array coding problem

OA [CodeSignal] Balanced Numbers in Permutation Given a permutation p of integers from 1 to n. A number k (where 1 <= k <= n) is called...

Input: Array
Output: Computed result
coding Hard Verified Question #3

3. OA [CodeSignal] Count Palindrome Paths in Tree


Category: Tree coding problem
Given a tree with n nodes where each node has a lowercase English character c[i]. A path is palindromic if the characters along the path can...
Input: List
Output: Computed result
coding Hard Verified Question #4

4. OA [CodeSignal] Max Throughput With Budget


Category: Algorithm coding problem
You have a pipeline of services. Each service has: - Current throughput throughput[i] - Cost to scale up by 1 unit scalecost[i] You have a fixed...
Input: List
Output: Integer
coding Hard Verified Question #5

5. OA [CodeSignal] Minimum Edge Reversal Root


Category: Graph coding problem
Given a directed graph (represented as a tree with directed edges), choose a root node such that the minimum number of edges must be reversed so that...
Input: Graph (nodes and edges)
Output: Integer
coding Hard Verified Question #6

6. OA [CodeSignal] Purchase Optimization


Category: Array coding problem
Alex is shopping at Ozone Gallerie Mall where cubicles are arranged in non-decreasing order of prices from left to right. Given: - prices: array of...
Input: Array
Output: Integer
coding Hard Verified Question #7

7. OA [CodeSignal] Touring the Building


Category: Algorithm coding problem
You are on floor 0 of a building and need to reach floor n. You can use either the lift or stairs. Lift: - Takes t1 time per floor -...
Input: Given input
Output: Computed result
coding Hard Verified Question #8

8. [Low Level Design] Uber Eats Price Calculation


Category: Algorithm coding problem
In the Uber Eats marketplace, the final price of an order is a dynamic calculation involving multiple factors. Design the core classes and interfaces...
Input: Given input
Output: Computed result
coding Hard Verified Question #9

9. Capital Gains Tax Calculator


Category: String coding problem
You are given a chronologically sorted list of stock transactions. Each transaction is a list of strings in the format `[<timestamp>, <type>,...
Input: Array of strings
Output: Computed result
coding Hard Verified Question #10

10. Longest Valid Container Nesting


Category: String coding problem

Longest Valid Container Nesting You are given a string consisting only of the characters {, }, [, ], (, ). These represent three levels...

Input: String
Output: Integer
coding Hard Verified Question #11

11. Palindrome Paths From Query


Category: Tree coding problem

Palindrome Paths From Query A disk stores hierarchical data in an undirected tree with tree_nodes nodes numbered from 0 to tree_nodes - 1,...

Input: Array
Output: Computed result
system design Hard Verified Question #12

12. Top 6 Recently Asked Uber System Design Questions


Category: Graph system design problem
This collection covers the most frequently asked system design questions at Uber interviews.
Input: Graph (nodes and edges)
Output: Computed result
coding Hard graph #1

1. [Graph] — Earliest connectivity with added and removed ride interactions


Background
Uber's reported interview prompt models timestamped ride interactions as connections between users and asks when everyone becomes connected. This version incorporates the reported removal follow-up: an interaction can expire or be invalidated, so connectivity may disappear as well as appear. Treat this as an interview graph model, not a description of Uber's production architecture.
Problem statement
You are given n users numbered 0 through n - 1 and a chronological list of interaction events. Initially, there are no active connections. Each event is a tuple (timestamp, operation, u, v):
  • "add" activates an undirected connection between users u and v.

  • "remove" deactivates that connection.


An addition always refers to an inactive connection, and a removal always refers to an active connection. The same connection may be added again after removal. Endpoint order does not matter.
Return the earliest timestamp immediately after processing an event at which every user can reach every other user through active connections. Return -1 if this never occurs. If n == 1, return 0, because the network is already connected before any events.
All events are available before processing begins. Your algorithm must handle removals correctly; connectivity is not monotonic over time.
Function signature
  • earliest_connected(n: int, events: list[tuple[int, str, int, int]]) -> int


Example 1:
Input:
{
  "n": 3,
  "events": [
    [2, "add", 0, 1],
    [4, "remove", 1, 0],
    [6, "add", 1, 2],
    [9, "add", 0, 2]
  ]
}
Output:
9
Explanation: At time 2, user 2 is isolated. At time 4, the only connection disappears. At time 6, user 0 is isolated. At time 9, connections 1–2 and 0–2 connect all three users. A union-find that ignores removals would incorrectly return 6.
Example 2:
Input:
{
  "n": 4,
  "events": [
    [1, "add", 0, 1],
    [3, "add", 2, 3],
    [5, "remove", 0, 1],
    [7, "add", 1, 2]
  ]
}
Output:
-1
Explanation: At time 3, there are two components: {0, 1} and {2, 3}. The connection 0–1 disappears before 1–2 appears. At time 7, user 0 remains isolated, so the graph never becomes connected.
Constraints:
  • 1 <= n <= 200000.

  • 0 <= len(events) <= 200000.

  • Timestamps are integers in [1, 10^18] and are strictly increasing.

  • Each operation is exactly "add" or "remove".

  • 0 <= u, v < n and u != v.

  • All additions and removals are valid under the active-connection rules above.

  • Rebuilding the graph or traversing all users after every event is too slow at the maximum bounds.


Follow-up:
Now events arrive online, and after each event you must report whether the graph is currently connected without knowing future removals. Explain why the offline approach no longer applies and what additional data structures would be needed to support replacement connections after deleting an edge from a spanning forest.
Want to practise this one?
Create a free account to open the full question and practise Uber questions with AI.
Sign up free
coding Hard graph #2

2. [AI Enabled Coding] Dispatch Coverage Readiness Monitor


Scenario


Uber's dispatch operations team wants to replay changes to a city's enabled pickup coverage before a rollout. In this simplified planning model, coverage is represented by grid cells: two enabled cells belong to the same dispatch region if they share a side, directly or through other enabled cells. Build a batch analyzer that reports coverage fragmentation and, later, readiness around important pickup locations; you may use an AI assistant while coding.

Part 1 — Citywide coverage checks


  • Initially, no cells are enabled. Process records in input order and produce one result after every record.

  • Each record is a map with string keys and string values. Every record has event_id and action. An activate record also has row and col, encoded as decimal integer strings. A query record has no coordinates.

  • activate enables a cell. Activating an already enabled cell is a no-op. query changes nothing.

  • Cells are adjacent only when their coordinates differ by exactly 1 in one dimension and are equal in the other. Diagonal cells are not adjacent.

  • Report active_cells, components, and largest_component, where component size is measured in enabled cells. All three metrics are zero when coverage is empty.

  • Emit FRAGMENTED if components > 2. Emit THIN_SUPPLY if active_cells > 0 and largest_component < 3. These are planning-model labels, not claims about Uber's production policies. Return flags in lexicographic order.

  • Use this function signature: evaluate_coverage(records: list[dict[str, str]]). The return type is up to you; discuss your choice. The examples use a JSON list of snapshots.


Example 1:


Input:
{
  "records": [
    {"event_id": "e0", "action": "query"},
    {"event_id": "e1", "action": "activate", "row": "0", "col": "0"},
    {"event_id": "e2", "action": "activate", "row": "0", "col": "1"},
    {"event_id": "e3", "action": "activate", "row": "0", "col": "3"},
    {"event_id": "e4", "action": "activate", "row": "1", "col": "0"},
    {"event_id": "e5", "action": "activate", "row": "3", "col": "0"}
  ]
}

Output:
[
  {"event_id": "e0", "active_cells": 0, "components": 0, "largest_component": 0, "flags": []},
  {"event_id": "e1", "active_cells": 1, "components": 1, "largest_component": 1, "flags": ["THIN_SUPPLY"]},
  {"event_id": "e2", "active_cells": 2, "components": 1, "largest_component": 2, "flags": ["THIN_SUPPLY"]},
  {"event_id": "e3", "active_cells": 3, "components": 2, "largest_component": 2, "flags": ["THIN_SUPPLY"]},
  {"event_id": "e4", "active_cells": 4, "components": 2, "largest_component": 3, "flags": []},
  {"event_id": "e5", "active_cells": 5, "components": 3, "largest_component": 3, "flags": ["FRAGMENTED"]}
]

Explanation: At e4, cells (0,0), (0,1), and (1,0) form a component of size 3; (0,3) is separate. At e5, (3,0) creates a third component, exceeding the component cap of 2.

Part 2 — Reversible coverage and pickup-zone readiness


Operations must now replay coverage withdrawals and evaluate airport, station, and venue pickup zones. A cell withdrawal can split an existing component, which an ordinary addition-only union-find does not handle.
Add evaluate_zoned_coverage(records: list[dict[str, str]], zones: list[dict[str, str]]), retaining every Part 1 behavior and flag:
  • Accept deactivate, with row and col fields. It disables the cell; disabling an already disabled cell is a no-op.

  • Each zone is a string-valued map with zone_id, cells, and min_active. cells is a nonempty semicolon-separated list of distinct row,col coordinates, such as "0,0;0,1". min_active is a positive decimal integer no larger than the zone's number of cells.

  • After every event, report each zone's number of enabled member cells. Its status is READY when this count is at least min_active, otherwise UNDER_COVERED. Zone readiness does not depend on connectivity, and zones may overlap.

  • Return zones in lexicographic zone_id order. The examples place the unchanged Part 1 snapshot under global and add a zones list.

  • Discuss how your return type changes before implementing this extension. The design must support future pickup zones through configuration rather than zone-specific branches, and citywide flag rules should be independently extensible.

  • The entire event batch is available before processing. Avoid recomputing connected components by traversing all enabled cells after every event.


Example 2:


Input:
{
  "records": [
    {"event_id": "r1", "action": "activate", "row": "0", "col": "0"},
    {"event_id": "r2", "action": "activate", "row": "0", "col": "1"},
    {"event_id": "r3", "action": "activate", "row": "0", "col": "2"},
    {"event_id": "r4", "action": "deactivate", "row": "0", "col": "1"}
  ],
  "zones": [
    {"zone_id": "station", "cells": "0,0;0,1", "min_active": "2"}
  ]
}

Output:
[
  {"global": {"event_id": "r1", "active_cells": 1, "components": 1, "largest_component": 1, "flags": ["THIN_SUPPLY"]}, "zones": [{"zone_id": "station", "active_cells": 1, "min_active": 2, "status": "UNDER_COVERED"}]},
  {"global": {"event_id": "r2", "active_cells": 2, "components": 1, "largest_component": 2, "flags": ["THIN_SUPPLY"]}, "zones": [{"zone_id": "station", "active_cells": 2, "min_active": 2, "status": "READY"}]},
  {"global": {"event_id": "r3", "active_cells": 3, "components": 1, "largest_component": 3, "flags": []}, "zones": [{"zone_id": "station", "active_cells": 2, "min_active": 2, "status": "READY"}]},
  {"global": {"event_id": "r4", "active_cells": 2, "components": 2, "largest_component": 1, "flags": ["THIN_SUPPLY"]}, "zones": [{"zone_id": "station", "active_cells": 1, "min_active": 2, "status": "UNDER_COVERED"}]}
]

Explanation: The first three events build a connected chain with sizes 1, 2, and 3. Removing its middle cell leaves 3 - 1 = 2 enabled cells in two singleton components. The station count falls from 2 to 2 - 1 = 1, below its minimum of 2. Two components do not exceed the fragmentation cap, but a largest component of 1 triggers THIN_SUPPLY.

Example 3:


Input:
{
  "records": [
    {"event_id": "s1", "action": "activate", "row": "0", "col": "0"},
    {"event_id": "s2", "action": "activate", "row": "0", "col": "2"},
    {"event_id": "s3", "action": "activate", "row": "2", "col": "0"},
    {"event_id": "s4", "action": "deactivate", "row": "9", "col": "9"},
    {"event_id": "s5", "action": "query"}
  ],
  "zones": [
    {"zone_id": "airport", "cells": "0,0;0,1", "min_active": "2"}
  ]
}

Output:
[
  {"global": {"event_id": "s1", "active_cells": 1, "components": 1, "largest_component": 1, "flags": ["THIN_SUPPLY"]}, "zones": [{"zone_id": "airport", "active_cells": 1, "min_active": 2, "status": "UNDER_COVERED"}]},
  {"global": {"event_id": "s2", "active_cells": 2, "components": 2, "largest_component": 1, "flags": ["THIN_SUPPLY"]}, "zones": [{"zone_id": "airport", "active_cells": 1, "min_active": 2, "status": "UNDER_COVERED"}]},
  {"global": {"event_id": "s3", "active_cells": 3, "components": 3, "largest_component": 1, "flags": ["FRAGMENTED", "THIN_SUPPLY"]}, "zones": [{"zone_id": "airport", "active_cells": 1, "min_active": 2, "status": "UNDER_COVERED"}]},
  {"global": {"event_id": "s4", "active_cells": 3, "components": 3, "largest_component": 1, "flags": ["FRAGMENTED", "THIN_SUPPLY"]}, "zones": [{"zone_id": "airport", "active_cells": 1, "min_active": 2, "status": "UNDER_COVERED"}]},
  {"global": {"event_id": "s5", "active_cells": 3, "components": 3, "largest_component": 1, "flags": ["FRAGMENTED", "THIN_SUPPLY"]}, "zones": [{"zone_id": "airport", "active_cells": 1, "min_active": 2, "status": "UNDER_COVERED"}]}
]

Explanation: At s3, the total is 1 + 1 + 1 = 3 isolated cells. Both citywide rules fire: 3 > 2 components and 1 < 3 cells in the largest component. Only (0,0) belongs to the airport zone, so its count remains 1 < 2. Removing absent cell (9,9) and issuing a query change nothing.

Notes:


  • There are at most 50,000 events, at most 10 zones, and at most 100,000 total configured zone-cell memberships. Coordinates are integers between -1,000,000,000 and 1,000,000,000; the grid is sparse and unbounded within that range.

  • Inputs are well formed; event IDs and zone IDs are unique within their respective lists. An empty event list returns an empty result, and an empty zone list is allowed.

  • This is a deterministic offline replay, not a concurrent service. Report state after each event, including no-ops, and do not infer enabled cells from zone configuration.
coding Hard sliding window #3

3. [OA] Sliding Window — Maximize ride-sharing revenue during peak hours

Uber aims to maximize revenue by optimizing surge pricing during peak hours. The challenge is to calculate the maximum number of rides that can occur in any contiguous window of time.
Given an array representing the number of rides requested at each time interval, implement a function that finds the maximum number of rides that can be accommodated within a contiguous window of size k.
  • def max_rides_in_window(rides: List[int], k: int) -> int

- Returns the maximum number of rides in any contiguous window of size k.
Example 1:
Input: rides = [2, 1, 5, 1, 3, 2], k = 3
Output: 9
Explanation: The maximum rides in the window [5, 1, 3] is 9.
Example 2:
Input: rides = [1, 2, 3, 4, 5], k = 2
Output: 9
Explanation: The maximum rides in the window [4, 5] is 9.
Constraints:
  • 1 <= len(rides) <= 10^5

  • 1 <= rides[i], k <= 10^4.
coding Hard graph #4

4. [OA] Dijkstra's Algorithm — Find the shortest route for ride-sharing optimizations

Uber's ride-sharing services rely on efficient routing to minimize wait times and optimize driver assignments. The goal is to find the shortest path between two locations in a network of paths.
Given a graph represented as an adjacency list where each edge has a non-negative weight, implement a function that finds the shortest distance from a starting node to a destination node.
  • def dijkstra(graph: Dict[int, List[Tuple[int, int]]], start: int, destination: int) -> int

- Returns the shortest distance from start to destination.
Example 1:
Input: graph = {0: [(1, 1), (2, 4)], 1: [(2, 2), (3, 6)], 2: [(3, 1)], 3: []}, start = 0, destination = 3
Output: 3
Explanation: The path 0 -> 1 -> 2 -> 3 has a total weight of 3.
Example 2:
Input: graph = {0: [(1, 2)], 1: [(2, 3)], 2: [(3, 1)], 3: []}, start = 0, destination = 3
Output: 6
Explanation: The path 0 -> 1 -> 2 -> 3 has a total weight of 6.
Constraints:
  • 1 <= len(graph) <= 10^4

  • 0 <= start, destination < len(graph)

  • Each edge's weight is a positive integer.
system design Hard api design #5

5. [OA] Twitter Feed — Design a feed system for real-time updates

Uber has a feature to notify drivers of nearby ride requests in real-time. Implement a Twitter-like feed system that delivers updates to users based on user subscriptions to certain categories, allowing users to add, remove, and fetch their feeds.
  • class Feed:

- def add_category(self, user_id: int, category: str) -> None — Add a category to the user's subscription.
- def remove_category(self, user_id: int, category: str) -> None — Remove a category from the user's subscription.
- def get_feed(self, user_id: int) -> List[str] — Return the feed of updates for the user.
Example 1:
Input: feed = Feed(), feed.add_category(1, 'Ride'), feed.add_category(1, 'Promo'), feed.get_feed(1)
Output: ['Ride', 'Promo']
Explanation: User 1 subscribes to 'Ride' and 'Promo' categories.
Example 2:
Input: feed.remove_category(1, 'Promo'), feed.get_feed(1)
Output: ['Ride']
Explanation: User 1 unsubscribes from 'Promo'.
Constraints:
  • The maximum number of users is 1 <= user_id <= 10^4.

  • The maximum number of categories is 1 <= category_count <= 100.
system design Hard caching #6

6. [OA] LRU Cache — Implementing Uber's demand caching system

With millions of users, Uber needs an efficient way to cache frequently requested ride demand data. Implement an LRU (Least Recently Used) cache that allows adding, retrieving, and evicting ride demand based on their usage.
  • class LRUCache:

- def __init__(self, capacity: int) — Initializes the LRU cache.
- def get(self, key: int) -> int — Returns the value of the key if the key exists.
- def put(self, key: int, value: int) — Updates the value of the key or adds the key-value pair.
Example 1:
Input: lru = LRUCache(2), lru.put(1, 1), lru.put(2, 2), lru.get(1)
Output: 1
Explanation: Key 1 is present, returning its value.
Example 2:
Input: lru.put(3, 3), lru.get(2)
Output: -1
Explanation: Key 2 was evicted because it was least recently used.
Constraints:
  • The capacity of the cache is 1 <= capacity <= 10^4.

  • All keys and values are in the range of 1 <= key, value <= 10^5.

Start practicing Uber questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free