Find Every Dictionary Word Hidden in a Letter Tile Board

Last updated: November 29, 2026

Quick Overview

Given a grid of letters and a list of words, return all words that can be formed by a path of horizontally or vertically adjacent cells, using each cell at most once per word.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Given a grid of letters and a list of words, return all words that can be formed by a path of horizontally or vertically adjacent cells, using each cell at most once per word.

In the style of a Google onsite question about building the solver for a word game, this tests whether you share work across words with a trie instead of running a separate search per word. Interviewers look for trie-guided DFS, in-place visited marking, and pruning of exhausted trie branches.

What the Interviewer Expects
  • Explains why one DFS per word repeats work across shared prefixes
  • Builds a trie of the words and DFS-es the board guided by trie children
  • Marks visited cells in place and restores them on backtrack
  • Records each found word once and removes it from the trie
  • Prunes empty trie nodes to speed up later searches
Key Topics to Cover
Trie
Backtracking
DFS
Grids
Pruning
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Diagonal moves are allowed and cells can be reused; what changes?
  • The board is fixed and many different word lists are queried; what would you precompute?
  • Return the highest-scoring set of non-overlapping words.
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: R by C board of lowercase letters, list of words (up to tens of thousands).
  • A word must follow 4-directional adjacency without reusing a cell.
  • Output: distinct found words, any order....
High-Level Design

Insert every word into a trie where each terminal node stores the word itself. From every cell, DFS while the current trie node has a child for the cell's letter. On entering a node that stores a word...


Submit Your Answer
Markdown supported