Reddit: Grid word search where the path must keep one fixed direction
Problem. Given a grid of letters and a word, decide whether the word appears in the grid. The rule that sank the candidate: once the word starts, every following letter has to continue in the same direction (straight lines, like a classic printed word search), not a path that can turn at each step.
What happened. The interviewer stated the task and then stayed mostly silent. The candidate did not confirm the movement rule and wrote a looser search that allowed turns. A typo cost about ten minutes. Their own tests passed, but near the end the interviewer pointed out the search had to stay in one direction, and there was no time left to rework it. The result was a rejection.
What the interviewer cared about. Pinning down requirements before writing code. Ask up front which directions count (horizontal, vertical, diagonal, reversed) and whether the path may bend.
Preparation tip. Practice both versions: the fixed-direction scan over eight direction vectors and the turning-path backtracking search, so you can switch quickly if the rule changes.
Comments 0
No comments yet. Ask the author something, or add what happened in your own round.