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
Coding & Algorithms
Software Engineer
Uber
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

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
trie
backtracking
grid DFS
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
  • 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 Problems
Sample Answer
Requirements
  • Input: m x n grid 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...


Submit Your Answer
Markdown supported