← Uber Interview Insights

Uber·Machine Learning Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Apr 2026Remote

Summary

Uber ML engineer screen, pretty much a graph traversal question dressed up with a bunch of follow-up variants. Not a bad round but you really need to know where the question is going before you start coding.

Questions Asked (1)

Q1

Given a 2D grid of land and water cells, count the number of islands, where an island is a group of land cells connected in four directions.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Classic BFS/DFS problem and I knew it, but I made the mistake of jumping straight into code without asking which variant they wanted.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints and edge cases, then explain a graph traversal approach (DFS/BFS) to explore connected land cells. Discuss trade-offs between iterative and recursive implementations, and analyze time and space complexity.

Pro tip: Mention that you can optimize space by marking visited cells in-place (e.g., changing '1' to '0') to avoid a separate visited set, and discuss how to handle very large grids that don't fit in memory.

1. Clarify the problem

Ask about grid dimensions, input format, and whether modifying the grid is allowed. Confirm that diagonal connections do not count.

2. Choose an algorithm

Select a graph traversal method like DFS or BFS to explore each island. Explain why it's suitable for this problem.

3. Handle visited cells

Decide how to track visited land cells. Discuss in-place modification versus using a separate visited set, and the trade-offs.

4. Implement and analyze

Write pseudocode or code, then analyze time and space complexity. Mention that time is O(rows * cols) and space is O(rows * cols) in the worst case for recursion.

5. Discuss extensions

Talk about handling large grids, parallelization, or using union-find as an alternative approach. Relate to ML engineering scenarios like image segmentation.

Key Points to Mention

  • Time complexity: O(rows * cols) because each cell is visited once.
  • Space complexity: O(rows * cols) for recursion stack in worst case (e.g., all land).
  • In-place modification of the grid to mark visited cells saves space.
  • Iterative BFS with a queue avoids recursion depth limits.
  • Union-Find (Disjoint Set) is an alternative with near-linear time.
  • Edge cases: empty grid, single row/column, all water, all land.

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