Uber logo

Uber Medium Interview Questions

23 medium-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
coding Medium Verified Question #1

1. Move Through Array


Category: Array coding problem

Move Through Array You are given an array where each element represents the number of steps you can move from that position. Positive numbers move...

Input: Array
Output: Computed result
coding Medium Verified Question #2

2. OA [CodeSignal] Final Prices After Discount


Category: Array coding problem
You are given an array prices where prices[i] is the price of an item. For each item at index i, find the first item at index j > i such that...
Input: Array
Output: Computed result
coding Medium Verified Question #3

3. OA [CodeSignal] Jump Game


Category: Array coding problem
You are at position i in an array. From each position, you can jump to: - i + 1 (one step forward) - Any position i + k where k ends in digit...
Input: Array
Output: Computed result
coding Medium Verified Question #4

4. OA [CodeSignal] Longest Subsequence With Limited Sum


Category: Array coding problem
You are given two arrays: nums (containing positive integers) and queries (each containing a target sum). For each query, return the maximum...
Input: Array
Output:** Computed result
coding Medium Verified Question #5

5. OA [CodeSignal] Minimum Operation To Reduce n To 0


Category: Algorithm coding problem
Given a positive integer n, in one operation you may replace n with either: - n = n + 2^i, or - n = n - 2^i for any integer i >= 0. Find...
Input: Integer(s)
Output: Integer
coding Medium Verified Question #6

6. OA [CodeSignal] Shortest Good Subarray


Category: Array coding problem
Given an array arr and an integer k, a subarray is called good if it contains at least k distinct integers. Return the length of the...
Input: Array
Output: Integer
coding Medium Verified Question #7

7. Robot Map


Category: Array coding problem
Given a location map and a query, find which robot matches the query. Location Map: A 2D array where each cell contains: - O = Robot - E =...
Input: Array
Output: Computed result
coding Medium Verified Question #8

8. [Object Oriented Design] Meeting Reservation System


Category: Interval-based coding problem

Meeting Reservation System Design a meeting reservation system that manages meeting rooms and schedules. Implement a MeetingReservationSystem...

Input: Integer(s)
Output: Computed result
coding Medium Verified Question #9

9. Unimodal Cost Function Minimum


Category: Interval-based coding problem

Unimodal Cost Function Minimum You are given a unimodal cost function f(x) = A * (x - C)^2 + D defined over the interval [lo, hi], where `A >...

Input: Given input
Output: Computed result
coding Medium Verified Question #10

10. Hierarchy Path Finder


Category: Tree coding problem

Hierarchy Path Finder You are given an org chart represented as a tree. Each node in the tree has a unique integer ID and a display name. You are...

Input: List
Output: Computed result
coding Medium Verified Question #11

11. Weight Partition Check


Category: Algorithm coding problem

Weight Partition Check You are given a list of distinct positive integer weights and a capacity value. Determine whether any subset of the weights...

Input: List
Output: Computed result
coding Medium Verified Question #12

12. Straight Line Sequence Search


Category: Grid/matrix coding problem

Straight Line Sequence Search You are given an m x n grid of characters and a target sequence string. Determine whether the sequence appears in...

Input: 2D grid
Output: Computed result
coding Medium Verified Question #13

13. Next Palindrome Number


Category: String coding problem

Next Palindrome Number Given a string num representing a positive integer, find and return the smallest palindrome that is strictly greater than...

Input: String
Output: Computed result
coding Medium Verified Question #14

14. Nested Arithmetic Expression Evaluator


Category: String coding problem

Nested Arithmetic Expression Evaluator You are given a string expression containing nested calls to two functions: plus(a, b) and minus(a, b)....

Input: String
Output: Computed result
coding Medium Verified Question #15

15. Process CPU Time Calculator


Category: Interval-based coding problem
You are given a list of log entries from a single-threaded CPU scheduler. Each entry is a list of three strings: [process_name, action, timestamp],...
Input: Array of strings
Output: Computed result
coding Medium Verified Question #16

16. OA [CodeSignal] Prime Jumps


Category: Algorithm coding problem

OA [CodeSignal] Prime Jumps A game is played with the following rules: - A player starts at cell 0 with a score of 0. - There is a row of n cells...

Input: Number(s)
Output: Computed result
coding Medium graph #1

1. Graph — Find the shortest path for ride requests

Background: Uber needs an efficient way to assign drivers to ride requests, optimizing for time and distance. The solution involves finding the shortest paths in a dynamic city environment with varying traffic conditions.
Problem statement: Given a graph representing the city's road network, where each edge has a weight representing time to travel, implement a function that finds the shortest path from a driver's current location to a ride request's pickup point. The function should return the total time taken and the path taken as a list of locations.
Function/class signature:
  • def shortest_path(graph: Dict[str, List[Tuple[str, int]]], start: str, end: str) -> Tuple[int, List[str]]:


Example 1:
Input: graph = {'A': [('B', 2), ('C', 5)], 'B': [('A', 2), ('C', 1)], 'C': [('A', 5), ('B', 1)]}
start = 'A', end = 'C'
Output: (3, ['A', 'B', 'C'])
Explanation: The shortest path from A to C is via B with a total travel time of 3.
Example 2:
Input: graph = {'A': [('B', 4), ('D', 1)], 'B': [('A', 4), ('C', 1)], 'C': [('B', 1), ('D', 3)], 'D': [('A', 1), ('C', 3)]}
start = 'A', end = 'C'
Output: (5, ['A', 'D', 'C'])
Explanation: The shortest path from A to C is via D with a total travel time of 5.
Constraints:
  • 1 ≤ |graph| ≤ 1000 (number of locations)

  • 1 ≤ time ≤ 10^4

  • All locations are unique strings.
coding Medium graph #2

2. CODING — Shortest Path in a Grid with Blocked Cells

Background: In Uber's navigation system, finding the most efficient route for drivers is crucial. This problem relates to optimizing routes in urban environments where not all paths are accessible due to traffic or road closures.
Problem statement: You are given a 2D grid representing a map where 0 represents a free cell and 1 represents a blocked cell. You need to find the shortest path from the top-left corner (0, 0) to the bottom-right corner (n-1, m-1). If there is no possible path, return -1.
Function/class signature:
  • def shortest_path(grid: List[List[int]]) -> int:

Example 1:
Input: [[0, 0, 0], [0, 1, 0], [0, 0, 0]]
Output: 4
Explanation: The path is: down → down → right → right.
Example 2:
Input: [[0, 1], [1, 0]]
Output: -1
Explanation: There is no path to the destination.
Constraints:
  • 1 <= grid.length, grid[i].length <= 100

  • Grid cells contain either 0 or 1 (where 1 is a blocked cell).
coding Medium dynamic programming #3

3. Dynamic Programming — Unique Paths in a Grid

Background: In Uber's ride-sharing application, calculating the most efficient routes is paramount. This problem involves finding the number of unique ways to traverse a grid from the top-left corner to the bottom-right corner, simulating potential routes.
Problem statement: Given a m x n grid, you start at the top-left corner and can only move either down or right at any point in time. Your task is to find how many unique paths there are to reach the bottom-right corner. Implement a function named uniquePaths that takes two integers, m and n, and returns the number of unique paths.
Function/class signature:
  • def uniquePaths(m: int, n: int) -> int:

Example 1:
  • Input: m = 3, n = 7

  • Output: 28

  • Explanation: There are 28 unique paths to reach the bottom-right corner from the top-left corner in a 3x7 grid.

Example 2:
  • Input: m = 3, n = 2

  • Output: 3

  • Explanation: There are 3 unique paths in a 3x2 grid.

Constraints:
  • 1 <= m, n <= 100

  • The grid can be as large as 100x100, resulting in a maximum of 10,000 squares.
coding Medium graph #4

4. Shortest Path in a Grid with Blocked Cells — finding the optimal route for a rider

1. Background: When routing drivers to pick up passengers, Uber needs to find the most efficient path on a grid where certain cells may be blocked due to construction, accidents, or other obstacles. This ensures reliability in its service delivery.
2. Problem statement: Given a n x m grid, where cells can either be open (0) or blocked (1), determine the shortest path from the top-left corner (0, 0) to the bottom-right corner (n-1, m-1). Return the length of the path, if it exists, or -1 if there is no valid path.
3. Function/class signature:
- def shortest_path(grid: List[List[int]]) -> int:
4. Example 1:
Input: [[0, 0, 0], [0, 1, 0], [0, 0, 0]]
Output: 4
Explanation: The path is (0,0) → (0,1) → (0,2) → (1,2) → (2,2).
5. Example 2:
Input: [[0, 1], [1, 0]]
Output: -1
Explanation: There is no valid path due to the blocks.
6. Constraints:
- 1 <= n, m <= 100
- grid[i][j] is either 0 or 1.
- grid[0][0] and grid[n-1][m-1] are guaranteed to be 0.
coding Medium graph #5

5. GRID-BASED PATHFINDING — Implement a solution to find the shortest path on a grid with blocked cells

Background: Uber has to optimize routes for drivers, especially in areas with obstacles, making real-time pathfinding crucial. This challenge reflects the need for efficient algorithms in ride-sharing logistics.
Problem statement: Given a n x m grid where 0 represents an open cell and 1 represents a blocked cell, write a function that finds the shortest path from the top-left corner (0, 0) to the bottom-right corner (n-1, m-1). You can only move right, down, left, or up. If there is no valid path, return -1.
Function signature: def shortest_path(grid: List[List[int]]) -> int:
Example 1:
Input: [[0,0,0],[0,1,0],[0,0,0]]
Output: 4
Explanation: The shortest path is (0,0) -> (0,1) -> (0,2) -> (1,2) -> (2,2).
Example 2:
Input: [[0,1,0],[1,1,0],[0,0,0]]
Output: 5
Constraints:
  • 1 <= n, m <= 100

  • The value of grid[i][j] is either 0 or 1.

  • The grid is always guaranteed to have a start cell and an end cell.
coding Medium graph #6

6. Title: [Graph] — Implement a pathfinding algorithm for ride-sharing requests

Background: In Uber's platform, efficiently determining the best route for drivers when multiple ride requests come in is crucial to reducing wait times and improving service quality. A pathfinding algorithm can help optimize routing for drivers based on a grid-based map of the service area.
Problem statement: Given a grid of size m x n, where empty cells are represented by 0 and obstacles are represented by 1, you need to implement an algorithm to find the shortest path from the top-left corner (0, 0) to the bottom-right corner (m-1, n-1). The path can only move down or right. Your task is to return the length of the shortest path or -1 if no such path exists.
Function/class signature:
  • def shortest_path(grid: List[List[int]]) -> int:


Example 1:
Input: [[0,0,0],[0,1,0],[0,0,0]]
Output: 4
Explanation: The path goes right, down, down, right.
Example 2:
Input: [[0,1,0],[0,1,0],[0,0,0]]
Output: -1
Explanation: No path exists due to the obstacles.
Constraints:
  • 1 <= m, n <= 100

  • grid[i][j] is either 0 (empty) or 1 (obstacle).
coding Medium graph #7

7. Graph — Shortest Path Problem in Ride-Hailing

Background: Uber relies on efficient routing to optimize ride dispatch for drivers and passengers. Real-time shortest path calculation can significantly improve user experience and reduce wait times.
Problem statement: You are tasked with finding the shortest path between two locations represented by a graph. Each edge in the graph represents a route between destinations and has an associated travel time. Given the start and end nodes, implement an algorithm to calculate the minimum travel time.
Function/class signature:
  • def shortest_path(graph: Dict[str, List[Tuple[str, int]]], start: str, end: str) -> Tuple[int, List[str]]:

Example 1:
Input:
graph = { 'A': [('B', 5), ('C', 10)], 'B': [('D', 2)], 'C': [('D', 1)], 'D': [] }
start = 'A'
end = 'D'
Output:
(7, ['A', 'B', 'D'])
Explanation: The shortest path from A to D is A -> B -> D with a total travel time of 7.
Example 2:
Input:
graph = { 'A': [('B', 1),('C', 5)], 'B': [('C', 2), ('D', 4)], 'C': [('D', 1)], 'D': [] }
start = 'A'
end = 'D'
Output:
(5, ['A', 'B', 'C', 'D'])
Constraints:
  • 1 <= len(graph) <= 100

  • Each edge time (travel time) is between 1 and 100, inclusive.

  • Graph is directed and may contain cycles.

Start practicing Uber questions

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

Get Started Free