← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Uber SWE interview with a classic board search problem. Nothing too surprising but the pruning optimization is where they actually care whether you know what you're doing.

Questions Asked (1)

Q1

Given a 2D board of characters and a list of words, find all words that can be formed by tracing a path through adjacent cells (horizontally or vertically), without reusing any cell in a single word.

Algorithms & Data Structures
Author's notes

You kind of have to go Trie plus DFS here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the board as a graph and use a Trie to store the word list for efficient prefix pruning. Perform DFS from each cell, marking visited cells and backtracking, while checking the Trie to collect valid words. Optimize by stopping early when no words share the current prefix.

Pro tip: Mention that you can further optimize by removing matched words from the Trie to avoid duplicate searches, and discuss trade-offs between time and space complexity. Also, clarify assumptions about input size and character set.

1. Clarify requirements and constraints

Ask about board dimensions, word list size, character set, and whether words can be reused. Confirm that paths can start and end anywhere and that each cell can be used at most once per word.

2. Choose data structures

Use a Trie to store the dictionary for O(1) prefix lookups and pruning. Use a 2D boolean array or modify the board in-place to track visited cells during DFS.

3. Design the DFS algorithm

For each cell, start a DFS that explores all four directions, checking if the current path forms a prefix in the Trie. If a complete word is found, add it to the result set.

4. Implement backtracking and pruning

Mark the current cell as visited before recursing and unmark it after. Prune the search when the current prefix is not in the Trie. Optionally, remove found words from the Trie to avoid duplicates.

5. Analyze complexity and edge cases

Discuss time complexity O(M * N * 4^L) where L is max word length, and space complexity O(total characters in words). Handle edge cases like empty board, empty word list, and single-character words.

Key Points to Mention

  • Use a Trie for efficient prefix matching and pruning.
  • Backtracking with visited cell tracking to avoid reuse.
  • DFS from each cell as a potential starting point.
  • Time and space complexity analysis.
  • Handling duplicate words and early termination.
  • Optimization: removing found words from Trie to reduce search space.

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