Eight-Direction Word Search
Updated
Problem statement
Given a rectangular grid of characters encoded as equal-length strings and a word, return whether the word can be formed from sequentially adjacent cells. Each step may move horizontally, vertically, or diagonally, and one cell cannot be reused within a path.
Function
wordExistsEightDirections(board: String[], word: String) → booleanExamples
Example 1
board = ["ABCE","SFCS","ADEE"]word = "ABCCED"return = trueExample 2
board = ["AB","CD"]word = "AD"return = trueThe diagonal move is allowed.
Constraints
1 <= board.length, board[i].length <= 50.1 <= word.length <= 50.- Board cells and the word contain English letters.
More Motive Onsite Interview questions
- Group AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2026
- Longest Equal-Zero-One SubarrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2026
- Maximum Weighted Sum After Left RotationsONSITE INTERVIEW · Seen Jan 2026
- Valid Parenthesis StringPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2026
- Best Time to Buy and Sell StockONSITE INTERVIEW · Seen Dec 2025
- Target Triplet SumONSITE INTERVIEW · Seen Dec 2025
- Validate IP AddressONSITE INTERVIEW · Seen Dec 2025
- Generate Palindromic PermutationsONSITE INTERVIEW · Seen Dec 2025
- Minimum Swaps to Group Circular OnesONSITE INTERVIEW · Seen Dec 2025
- Staircase Search In A Sorted MatrixONSITE INTERVIEW · Seen Dec 2025
Similar questions at other companies
- Enumerate Character Paths to a MarkerTesla · ONSITE INTERVIEWTesla interview questions
- Trace a Word Through a Letter GridExpedia · ONSITE INTERVIEWExpedia interview questions
- Word Search with Eight-Direction AdjacencyMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Cats, Rabbits, and Snails Board GameAsana · ONSITE INTERVIEW
- Matrix Flower-House Planting PlansGoogle · ONSITE INTERVIEWGoogle interview questions
- Boggle Word FinderBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
- Find a Word in a Letter GridAdobe · PHONE SCREENAdobe interview questions
- Generate All Permutations of a NumberFleetx · ONSITE INTERVIEW
- Assign Escalations to TeamsAmazon · ONSITE INTERVIEW
- Spiral MatrixAthenahealth · ONSITE INTERVIEW