← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Uber SWE interview that leaned hard into grid search problems. Two parts to the same question, and the second one is where things got interesting. Not a bad experience overall but definitely left me thinking about a few things I could've handled better.

Questions Asked (2)

Q1

Given a grid of uppercase letters and a target word, return true if the word appears in the grid by picking any starting cell and moving in one fixed direction (any of the 8 compass directions) for the entire word. Analyze the time and space complexity and explain how you'd avoid redundant checks.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This part felt manageable.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints (grid size, word length, case sensitivity) and then propose a brute-force approach that checks each cell as a starting point and each of the 8 directions, moving step by step. Then analyze the time complexity as O(R*C*8*L) and space as O(1) (or O(L) if recursive), and discuss optimizations like early termination, pruning, and avoiding redundant checks by not re-scanning the same path from different starting points.

Pro tip: Mention that you can precompute the first and last characters of the word and only start from cells matching the first character, and also check if the last character matches before traversing the full path to prune early. This shows attention to constant-factor optimizations that matter in production systems.

1. Clarify constraints and edge cases

Ask about grid dimensions, word length, whether the word can be empty, and if the grid can contain non-uppercase characters. This ensures you handle all cases correctly.

2. Outline brute-force approach

For each cell, try all 8 directions, and for each direction, check if the word matches by moving step by step. This is straightforward and easy to implement.

3. Analyze time and space complexity

Time: O(R*C*8*L) where R,C are grid dimensions and L is word length. Space: O(1) iterative, O(L) recursive due to call stack. Discuss how this scales.

4. Discuss optimizations and avoiding redundant checks

Prune by checking first and last characters, stop early if out of bounds or mismatch, and avoid re-checking the same path from different starting points by only starting from cells that match the first character.

5. Consider trade-offs and alternatives

Mention if the grid is large and many queries are expected, pre-processing (e.g., building a trie or suffix automaton) might be beneficial, but for a single query, brute-force is optimal.

Key Points to Mention

  • Time complexity: O(R*C*8*L) and space complexity: O(1) iterative or O(L) recursive.
  • Early termination: break as soon as a character mismatches or goes out of bounds.
  • Pruning: only start from cells matching the first character, and check last character before full traversal.
  • Avoid redundant checks: each starting cell and direction is unique, so no repeated work; but can skip if word length exceeds grid dimensions in that direction.
  • Edge cases: empty word (return true), word longer than any possible path, grid with single row/column.
  • Trade-offs: for multiple queries, pre-process grid into a trie or use dynamic programming, but for single query brute-force is simple and efficient.

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

Q2

Now extend the problem: the word can be formed by starting at any cell and moving to any orthogonal neighbor at each step, changing direction freely, but you cannot reuse a cell in a single path. Describe your algorithm, its complexity, and how this differs from the fixed-direction version. Also explain how you'd handle edge cases like an empty word, single characters, repeated letters, and large grids.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This is where I spent most of my time and honestly where things got messy.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem: given a grid of characters and a target word, determine if the word can be formed by a path of orthogonal moves without revisiting cells. Then describe a backtracking DFS that explores all possible starting cells and paths, with pruning and memoization where possible. Finally, analyze time and space complexity, contrast with the fixed-direction version, and address edge cases and scalability.

Pro tip: Emphasize that the worst-case complexity is exponential, but in practice, pruning (e.g., early termination, frequency checks) and memoization on (cell, index) states can drastically reduce the search space. Also, mention that for very large grids or long words, you might need to consider bidirectional search or A* with heuristics.

1. Clarify the problem and constraints

Restate the problem: find a simple path (no repeated cells) in a grid where consecutive cells are orthogonal neighbors and the characters spell the target word. Ask about grid size, word length, and whether multiple paths are allowed.

2. Describe the algorithm

Use DFS with backtracking: for each cell matching the first character, recursively explore all four directions, marking cells as visited and unmarking on backtrack. Prune by checking if remaining characters can possibly be formed (e.g., character frequency).

3. Analyze complexity

Time: O(N * M * 4^L) worst-case, where N*M is grid size and L is word length, but often much less due to pruning. Space: O(L) for recursion stack and visited set. Contrast with fixed-direction version which is O(N*M*L) if direction is fixed.

4. Handle edge cases

Empty word: return true. Single character: check if it exists in grid. Repeated letters: ensure visited set prevents reuse. Large grids: discuss optimizations like memoization, bidirectional search, or limiting search to cells with matching characters.

5. Discuss trade-offs and optimizations

Mention that while backtracking is straightforward, it may be slow for large inputs. Suggest optimizations: pre-check character counts, use bitsets for visited, or employ heuristic search (A*) if applicable.

Key Points to Mention

  • Backtracking DFS with visited set to avoid revisiting cells.
  • Pruning techniques: character frequency check, early termination when remaining length exceeds possible moves.
  • Complexity analysis: exponential worst-case, but practical performance depends on grid and word.
  • Difference from fixed-direction: fixed-direction restricts moves to a single direction (e.g., right and down), reducing branching factor and complexity.
  • Edge cases: empty word (true), single character (grid contains it), repeated letters (visited set handles), large grids (need optimizations).
  • Optimizations: memoization on (cell, index) if subproblems overlap, bidirectional search, or using a trie for multiple words.

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