Check Whether a Word Grid Reads the Same Across and Down
Last updated: November 29, 2026
Quick Overview
Given a list of words where word k is row k of a grid, return True if for every k the k-th row reads the same as the k-th column. Rows may have different lengths.
Meta
November 29, 20260
0
0 solved
Given a list of words where word k is row k of a grid, return True if for every k the k-th row reads the same as the k-th column. Rows may have different lengths.
A Meta phone screen question framed as validating a crossword-style word puzzle for a Messenger game. It is less about algorithms and more about precise index checks on ragged rows, which is where most candidates slip. Interviewers expect a single pass that never indexes out of range.
What the Interviewer Expects
- Restate the condition as words[r][c] == words[c][r] for all characters
- Check bounds before indexing on ragged rows
- Return early on the first mismatch
- Explain why visiting every character covers both directions
- Test with short trailing rows
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Build all valid word squares from a dictionary.
- What if the grid must also be square?
- How would you speed up repeated checks with a trie?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Up to 500 words, each up to 500 characters.
- Rows may be ragged; the grid is valid only if row k equals column k for every k....
High-Level Design
The grid reads the same across and down exactly when it is symmetric: every character at (r, c) must have a matching character at (c, r). So for each character, check that row c exists, that it ...