← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Uber phone screen for a SWE role, pretty much a single coding problem the whole time. The question was grid-based and had a decent follow-up that I wasn't fully ready for.

Questions Asked (2)

Q1

You're given a 2D grid with robots ('O'), empty cells ('E'), and blockers ('X'). Given a query of four distances [left, top, bottom, right] representing how far a cell is from the nearest blocker in each direction (grid boundaries count as blockers), return the positions of all robots whose distance profile exactly matches the query.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Started with brute force, scanning all four directions for each robot until hitting an X or the boundary.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Precompute distance profiles for all cells using four directional passes, then answer each query by checking robots whose profiles match. Optimize with hashing or grouping to handle multiple queries efficiently.

Pro tip: Mention that you can group robots by their distance profile to answer multiple queries in O(1) each, showing awareness of scalability for large grids and many queries.

1. Clarify the problem and constraints

Confirm grid dimensions, query frequency, and whether multiple queries need to be answered. Discuss input/output formats and edge cases like no robots or no matches.

2. Precompute distance profiles

For each cell, compute the distance to the nearest blocker in all four directions using dynamic programming: left-to-right, right-to-left, top-to-bottom, and bottom-to-top passes.

3. Index robots by profile

Store robots in a hash map keyed by their distance profile (tuple of four distances) to enable fast lookup for any query.

4. Answer queries efficiently

For each query, retrieve the list of robots with the matching profile from the hash map and return their positions. If no match, return an empty list.

5. Analyze complexity and trade-offs

Discuss time and space complexity: O(R*C) preprocessing, O(1) per query, and O(R*C) space. Mention alternatives like on-the-fly computation if memory is constrained.

Key Points to Mention

  • Dynamic programming for directional distances (four passes)
  • Hash map for O(1) query lookup by distance profile
  • Handling grid boundaries as blockers
  • Time and space complexity analysis
  • Trade-offs between precomputation and on-the-fly computation
  • Edge cases: no robots, no matches, multiple robots with same profile

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

Q2

Come up with a set of unit tests for this robot-matching function. What cases would you cover?

Algorithms & Data Structures
Author's notes

Follow-up that I did not see coming.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the function's contract: inputs, outputs, and edge cases. Then systematically cover normal cases, boundary conditions, invalid inputs, and performance considerations, organizing tests by category.

Pro tip: Mention that you'd write tests to be deterministic and independent, and consider using property-based testing for matching logic to catch unexpected edge cases.

1. Clarify the function contract

Ask about input types, expected output, and any constraints (e.g., time complexity, matching criteria). This ensures tests align with requirements.

2. Identify test categories

Break down tests into normal cases, edge cases, invalid inputs, and performance. This provides comprehensive coverage.

3. Design specific test cases

For each category, list concrete examples: e.g., empty input, single element, multiple matches, no matches, duplicate elements, large input.

4. Consider non-functional aspects

Include tests for performance (e.g., large input), determinism (same input yields same output), and idempotence if applicable.

5. Prioritize and explain

Highlight which tests are most critical and why, showing an understanding of risk and impact.

Key Points to Mention

  • Boundary conditions: empty input, single element, maximum size
  • Invalid inputs: null, wrong types, malformed data
  • Matching logic: exact matches, partial matches, no matches, multiple matches
  • Duplicates and ordering: how duplicates are handled, if order matters
  • Performance: time and space complexity for large inputs
  • Determinism and independence: tests should not depend on external state

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