Reach the Bottom-Right Cell Through Row or Column Word Matches
Company: Google
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: HR Screen
Overview: Test grid reachability through row or column jumps whose word endpoints match, using BFS, cycle prevention, and optional character-based adjacency indexes.
Constraints
- The grid is rectangular. Each dimension and the total cell count fit a signed 32-bit length.
- Each cell is a nonempty, well-formed Unicode string.
- Matching is exact and case-sensitive. A jump may land only within the same row or column.
Examples
Input: ([["ab", "xx", "bc"], ["zz", "uv", "cd"]],)
Expected Output: True
Explanation: Jump across the first row from ab to bc, then down to cd.
Input: ([["ab", "zx"], ["xy", "bc"]],)
Expected Output: False
Explanation: The bottom-right word starts with b, but it is diagonal from the start and no first jump is possible.
Hints
- When tracing a route, list which destinations share a row or column with the current cell.