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.
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
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- 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 ProblemsSample 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...