Quick Overview

Practice a Uber coding interview problem focused on determine whether a word exists in a character grid. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.

Determine Whether a Word Exists in a Character Grid

Company: Uber

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

Given a 2D character grid and a word, return whether the word can be formed by moving horizontally or vertically between adjacent cells without reusing a cell. Implement: ```python def exists_in_grid(board: list[list[str]], word: str) -> bool: pass ```

Overview: Practice a Uber coding interview problem focused on determine whether a word exists in a character grid. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.

Return whether a word exists by walking adjacent cells without reuse.

Examples

Input: {"board":[["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]],"word":"ABCCED"}

Expected Output: true

Explanation: Exists.

Input: {"board":[["A","B"],["C","D"]],"word":"ABCD"}

Expected Output: false

Explanation: Cannot jump.

Word Path in Character Grid

hardUberSoftware Engineer

Return whether a word exists by walking adjacent cells without reuse.

View full question (all parts)

Given a 2D character grid and a word, return whether the word can be formed by moving horizontally or vertically between adjacent cells without reusing a cell.

Implement:

def exists_in_grid(board: list[list[str]], word: str) -> bool:
    pass

Examples

Example 1
Input
{"board":[["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]],"word":"ABCCED"}
Output
true
Notes
Exists.
Example 2
Input
{"board":[["A","B"],["C","D"]],"word":"ABCD"}
Output
false
Notes
Cannot jump.

Comments (0)

No comments yet. Be the first to comment!

Submit your answer

Approved first answer today earns 30 XP
Bold⌘BItalic⌘IInline code⌘`Bullet listTab to nest (○ ■)Numbered listTab to nest (a. i.)QuoteCode block
Formatting help
Signature
def solution(board: list[list[str]], word: str) -> bool:
Sample input
{"board":[["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]],"word":"ABCCED"}
Language
Case 1
Input
{"board":[["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]],"word":"ABCCED"}
Expected
true
Case 2
Input
{"board":[["A","B"],["C","D"]],"word":"ABCD"}
Expected
false

Browse More Questions