← Uber Interview Insights

Uber·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
May 2026

Summary

Uber ML Engineer interview with a coding round focused on DFS and backtracking. Two problems back to back, both graph/recursion flavored. Not the most ML-heavy screen I expected.

Questions Asked (2)

Q1

Given an m x n grid where 1s represent land and 0s represent water, count the number of distinct connected land regions. Cells connect horizontally and vertically only.

Algorithms & Data Structures
Author's notes

Classic connected components problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Treat the grid as a graph and use DFS/BFS to explore each unvisited land cell, marking all connected land cells as visited. Each time you start a traversal from an unvisited land cell, increment the island count. Alternatively, use Union-Find to merge adjacent land cells and count distinct sets.

Pro tip: Clarify edge cases upfront (empty grid, all water, all land) and discuss trade-offs between DFS (recursive vs iterative to avoid stack overflow) and Union-Find (better for dynamic updates). Mention that in ML pipelines, similar connected-component logic is used in image segmentation and clustering.

1. Clarify problem and constraints

Confirm grid dimensions, connectivity (4-directional), and whether input can be modified. Ask about edge cases like empty grid or large sizes.

2. Choose an algorithm

Decide between DFS/BFS (simple, O(mn) time) or Union-Find (good for dynamic connectivity). Explain your choice based on constraints and potential follow-ups.

3. Outline traversal and marking

Describe how you'll iterate through cells, and when encountering an unvisited '1', increment count and traverse all connected '1's, marking them visited (e.g., set to '0' or use a visited matrix).

4. Analyze complexity and edge cases

State time and space complexity (O(mn) time, O(mn) space for visited or recursion stack). Discuss handling of empty grid, single row/column, and large grids.

5. Discuss optimizations and follow-ups

Mention iterative DFS to avoid recursion limits, Union-Find with path compression, or potential parallelization. Relate to ML applications like connected component labeling in images.

Key Points to Mention

  • Graph traversal (DFS/BFS) or Union-Find for connected components
  • Time complexity O(mn) and space complexity O(mn) in worst case
  • In-place modification vs visited matrix trade-offs
  • Handling edge cases: empty grid, all water, all land, large grids
  • Iterative vs recursive DFS to prevent stack overflow
  • Relevance to ML: connected component labeling in image segmentation, clustering

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Given a string of digits (e.g. '2345'), generate all letter strings it could represent using a phone keypad mapping, and also return the count of possible outputs.

Algorithms & Data Structures
Author's notes

Backtracking, straightforward enough.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a backtracking (DFS) approach to build letter combinations by processing digits one by one, appending mapped letters at each step. Alternatively, use an iterative BFS approach with a queue. After generating all combinations, return the list and its length as the count.

Pro tip: Clarify edge cases upfront: empty input, digits '0' or '1' (which have no letters), and whether the output should be sorted. Also mention that the count is simply the product of the number of letters per digit, but you'll generate the strings anyway.

1. Clarify requirements and edge cases

Ask about input constraints (e.g., string length, valid digits), expected output format (list of strings, count), and handling of '0'/'1' or empty input. Confirm if duplicates or sorting matter.

2. Define the phone keypad mapping

Create a mapping from digits 2-9 to their corresponding letters (e.g., 2: 'abc', 3: 'def', etc.). Note that 0 and 1 have no letters, so they should be handled as special cases.

3. Choose an algorithm (backtracking or iterative)

Use backtracking: recursively build combinations by iterating over letters for the current digit and recursing to the next. Or use iterative BFS: start with an empty string, and for each digit, append each letter to existing combinations.

4. Implement and handle edge cases

Write the code, ensuring that empty input returns an empty list (or list with empty string, depending on definition). If any digit is '0' or '1', return empty list (or skip). Also compute the count as the length of the result list.

5. Analyze complexity and test

Discuss time complexity O(4^n * n) where n is number of digits (since max 4 letters per digit) and space complexity O(n) for recursion stack (or O(4^n) for output). Test with examples like '23', '2345', and edge cases.

Key Points to Mention

  • Backtracking/DFS approach with recursion
  • Iterative BFS approach using a queue or list
  • Time complexity: O(4^n * n) where n is the number of digits
  • Space complexity: O(n) for recursion stack (excluding output)
  • Handling of digits '0' and '1' (no letters)
  • Count is simply the length of the generated list, or product of letter counts per digit

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.