Find a Word Along Adjacent Grid Cells
Company: Reddit
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Overview: Find a word in a character grid with backtracking, orthogonal adjacency, and no cell reuse, including repeated-letter cases and path-state restoration.
Constraints
- The grid is rectangular. Each dimension and the total number of cells fit a signed 32-bit length.
- Each cell is a string representing one well-formed Unicode code point.
- word is a well-formed Unicode string of at most 2^31 - 1 UTF-8 bytes.
Examples
Input: ([["C", "A", "T"], ["N", "R", "D"], ["O", "O", "G"]], "CARD")
Expected Output: True
Explanation: The path moves right to A, down to R, then right to D.
Input: ([["A", "S"], ["Z", "B"]], "AB")
Expected Output: False
Explanation: The only A and B are diagonal.
Hints
- Trace one tentative route and check which cells remain available after stepping back.