Problem
You get a grid of letters board with m rows and n columns, and a string word. Return true if you can find word in the grid. Otherwise, return false.
To find the word, start at a cell with the first letter. Then go to a neighbor cell for each next letter. Two cells are neighbors when they share a side, so you can go up, down, left or right.
You can use each cell at most one time for the word. Uppercase and lowercase letters are different.
Example 1
- Input:
- board = [["C","A","T"],["X","R","S"],["B","O","W"]], word = "CARS"
- Output:
- true
- Explanation:
- The path is
Cat (0, 0),Aat (0, 1),Rat (1, 1) andSat (1, 2).
Example 2
- Input:
- board = [["C","A","T"],["X","R","S"],["B","O","W"]], word = "BOX"
- Output:
- false
- Explanation:
Xat (1, 0) andOat (2, 1) touch only at a corner. A diagonal step is not allowed.
Example 3
- Input:
- board = [["C","A","T"],["X","R","S"],["B","O","W"]], word = "CAC"
- Output:
- false
- Explanation:
- The word needs a second
Cnext toA. The onlyCis already in use.
Constraints
- m == board.length
- n == board[i].length
- 1 <= m, n <= 6
- 1 <= word.length <= 15
- board and word contain only uppercase and lowercase English letters.
Follow-up
Can you stop the search early in more cases, so that it runs faster on a larger board?
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Word Search II
Coding · Array · Backtracking · Matrix
- Word Break II
Coding · Array · Backtracking · Dynamic Programming
- Accounts Merge
Coding · Array · Breadth-First Search · Depth-First Search
- Alien Dictionary
Coding · Array · Breadth-First Search · Depth-First Search
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 6 records
Amazon
Leetcode 79. Word Search
Reported Feb 28, 2025 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026
View sourceGlean
Leetcode 79. Word Search
Reported Apr 3, 2026 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026
View sourceGoogle
Leetcode 79. Word Search
Reported Dec 25, 2024 · 2 source reports
MID_LEVEL, SENIOR
Source snapshot: Nov 12, 2026
View sourceOracle
Leetcode 79. Word Search
Reported Jul 30, 2026 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026
View source