← Amazon Interview Insights

Amazon·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Apr 2026

Summary

Amazon SWE coding round with a twist on the classic word search problem. The modification allowing diagonal movement and cell reuse changes the problem enough that you can't just pull your standard solution from memory.

Questions Asked (1)

Q1

Given a 2D grid of characters, determine whether a given word can be formed by traversing sequentially adjacent cells, where adjacency includes diagonal neighbors and cells can be reused. Implement exist(grid, word) -> bool.

Algorithms & Data Structures
Author's notes

The diagonal part tripped me up at first because I had the standard 4-direction version basically memorized.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use DFS/backtracking from each cell that matches the first character, exploring all 8 directions. Since cells can be reused, no visited set is needed, but be mindful of infinite loops if the word has repeated characters and the grid allows cycles. Optimize by pruning branches early and considering BFS if the word is long.

Pro tip: Clarify with the interviewer whether diagonal adjacency is truly allowed and whether cell reuse means unlimited reuse or just within a single path. This shows attention to detail and avoids incorrect assumptions.

1. Clarify requirements and edge cases

Confirm adjacency definition (8-directional), cell reuse rules, and constraints (grid size, word length). Discuss edge cases like empty grid, empty word, or word longer than total cells.

2. Choose algorithm and data structures

Decide between DFS/backtracking and BFS. Since reuse is allowed, DFS with recursion is natural, but watch for cycles. Use a direction array for the 8 neighbors.

3. Implement search with pruning

Iterate over each cell; if it matches word[0], start DFS. At each step, check bounds, character match, and recurse for the next character. Prune if index reaches word length (success).

4. Analyze complexity and optimize

Time complexity: O(N * M * 8^L) worst-case, where L is word length. Discuss potential optimizations like early termination, memoization (if reuse not allowed), or bidirectional search.

5. Test and validate

Walk through examples, including cases with reuse and diagonal moves. Test edge cases like single-character word, no match, and large grids.

Key Points to Mention

  • 8-directional adjacency (including diagonals)
  • Cell reuse allowed, so no visited set, but beware of infinite recursion if cycles exist
  • DFS/backtracking approach with pruning
  • Time complexity analysis and potential optimizations
  • Edge cases: empty grid, empty word, word longer than grid cells
  • Clarify assumptions with interviewer before coding

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.