Medium · Backtracking
Word Search
Given an m × n grid of letters board and a string word, return true if word can be spelled by a path of horizontally or vertically adjacent cells that uses each cell at most once, and false otherwise.
Examples
Example 1
{
"board": [
["A", "B", "C", "E"],
["S", "F", "C", "S"],
["A", "D", "E", "E"]
],
"word": "ABCCED"
}Output: true
Example 2
{
"board": [
["A", "B", "C", "E"],
["S", "F", "C", "S"],
["A", "D", "E", "E"]
],
"word": "ABCB"
}Output: false
Rebuild it in the studio
Open every published interview problem, solution, scene, and memory room free, with no account.