← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Uber SWE interview with a classic grid search problem. Pretty standard coding round, nothing too surprising, but the backtracking edge cases will get you if you're not careful.

Questions Asked (1)

Q1

Given a 2D grid of characters and a target word, determine whether the word can be found in the grid by moving through horizontally or vertically adjacent cells, without reusing any cell.

Algorithms & Data Structures
Author's notes

Classic backtracking problem and I knew it the second I read it.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

This is a classic backtracking problem: iterate over each cell as a potential starting point, and perform DFS to match the target word character by character. At each step, explore all four adjacent cells, marking the current cell as visited to avoid reuse, and backtrack if no path works.

Pro tip: Before coding, clarify edge cases like empty word, empty grid, and whether diagonal moves are allowed. Also mention that you can optimize by checking character frequency counts upfront to quickly reject impossible cases.

1. Clarify the problem

Confirm movement rules (only horizontal/vertical), no cell reuse, and handle edge cases like empty word or grid. Ask if the word must be found exactly once or if multiple paths are acceptable.

2. Choose the algorithm

Use DFS with backtracking. For each cell that matches the first character, recursively search for the remaining characters in adjacent cells.

3. Implement DFS with visited tracking

Mark the current cell as visited (e.g., temporarily change its value or use a visited matrix), explore all four directions, and unmark it when backtracking.

4. Optimize and handle edge cases

Add early termination if the word is longer than the total cells. Optionally, pre-check character frequencies to quickly return false if the grid lacks required characters.

5. Analyze complexity

Time complexity is O(N * 3^L) where N is the number of cells and L is the word length (since each step has up to 3 unvisited neighbors). Space complexity is O(L) for recursion stack.

Key Points to Mention

  • Backtracking with DFS to explore all possible paths
  • Visited state management to prevent cell reuse (e.g., in-place marking or boolean matrix)
  • Base cases: empty word, word longer than grid, no matching start cell
  • Direction handling: up, down, left, right (no diagonals)
  • Time and space complexity analysis
  • Potential optimizations: character frequency check, early exit

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