Find Every Dish Name Hidden in a Menu Letter Board
Last updated: November 29, 2026
Quick Overview
Given a grid of letters from a promotional menu board and a list of dish names, return all dish names that can be traced by moving up, down, left or right through adjacent cells without reusing a cell in the same word.
Uber
November 29, 20260
0
0 solved
Given a grid of letters from a promotional menu board and a list of dish names, return all dish names that can be traced by moving up, down, left or right through adjacent cells without reusing a cell in the same word.
A hard Uber onsite coding question that pairs backtracking with a trie. Interviewers check that you search the grid once with all words at the same time instead of once per word, and that you prune.
What the Interviewer Expects
- Builds a trie of all dish names
- Runs DFS from each cell, following trie children only
- Marks cells as visited during the path and restores them on return
- Records a found word and removes it to avoid duplicates
- Prunes exhausted trie branches 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
- How does complexity scale with grid size and word length?
- What if diagonal moves are allowed?
- How would you parallelize across a very large board?
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:
m x ngrid of lowercase letters, list of distinct words. - Output: list of words found, any order.
- A cell can appear once per word path....
High-Level Design
Searching per word repeats the same grid walks. Instead insert all words into a trie where the final node stores the word. From each cell, DFS while the current letter is a child of the current trie n...