PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates skills in grid traversal, string-search and pattern-matching techniques, recursive backtracking, and the efficient use of data structures for prefix-based lookup, along with time and space complexity reasoning.

  • medium
  • Uber
  • Coding & Algorithms
  • Software Engineer

Find all dictionary words in a grid

Company: Uber

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given: - A 2D grid of characters `board` with `m` rows and `n` columns. - A list of strings `words` (a dictionary). A word can be formed by starting from any cell and moving to **adjacent** cells (up, down, left, right). Each cell may be used **at most once** in forming a single word. Return **all distinct** words from `words` that can be formed in the grid. ### Input - `board`: `m x n` array of lowercase letters. - `words`: list of lowercase strings. ### Output - A list (or set) of all dictionary words that appear in the board. ### Constraints (reasonable interview constraints) - `1 <= m, n <= 12` - `1 <= len(words) <= 3 * 10^4` - `1 <= len(word) <= 10` - Letters are lowercase `a-z`. ### Notes - The interviewer hinted that a **trie (prefix tree)** is a common approach, but a **backtracking** solution is also acceptable if performance is addressed.

Quick Answer: This question evaluates skills in grid traversal, string-search and pattern-matching techniques, recursive backtracking, and the efficient use of data structures for prefix-based lookup, along with time and space complexity reasoning.

Return sorted distinct dictionary words that can be formed by 4-directional backtracking without reusing a cell.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([['o','a','a','n'],['e','t','a','e'],['i','h','k','r'],['i','f','l','v']], ['oath','pea','eat','rain'])

Expected Output: ['eat', 'oath']

Explanation: Classic word search.

Input: ([['a']], ['a','b'])

Expected Output: ['a']

Explanation: Single cell.

Hints

  1. Use deterministic tie-breaking for prompts with multiple valid outputs.
  2. For design-style APIs, simulate operations with explicit inputs.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Thread-Safe Token-Bucket Rate Limiter - Uber
  • Quadtree for 2D Geospatial Points - Uber
  • Group Anagrams - Uber
  • Deep Equality of Two Records - Uber (medium)
  • Shortest Path in a Grid with Blocked Cells - Uber (medium)