Word Search II
Updated
Problem statement
Given an m x n board of lowercase English letters and an array of distinct lowercase words, return every word that can be formed on the board.
A word is formed by starting at any cell and repeatedly moving one cell horizontally or vertically. A board cell may be used at most once while forming a word.
Return the found words in the same order in which they appear in words.
Function
findWords(board: char[][], words: String[]) → List<String>Examples
Example 1
board = [["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l","v"]]words = ["oath","pea","eat","rain"]return = ["oath","eat"]The paths o-a-t-h and e-a-t use horizontal or vertical neighbors without reusing a cell. The other two words cannot be formed.
Example 2
board = [["a","b"],["c","d"]]words = ["abcb","abcd","acdb"]return = ["acdb"]acdb follows the path down, right, then up. Forming abcb would require reusing the b cell, and abcd would require a diagonal move.
Example 3
board = [["a"]]words = ["a","b"]return = ["a"]The one-cell board forms a but not b.
Constraints
1 <= m, n <= 121 <= words.length <= 300001 <= words[i].length <= 10- The board and every word contain only lowercase English letters.
- All words are distinct.
More Apple Phone Screen questions
- Subarray Product Less Than KPHONE SCREEN · Seen Nov 2026
- Evaluate DivisionPHONE SCREEN · Seen Nov 2026
- Reverse a Linked ListPHONE SCREEN · Seen Nov 2026
- Validate a BST with a Custom ComparisonPHONE SCREEN · Seen Nov 2026
- Design a Food Rating SystemPHONE SCREEN · Seen Oct 2026
- Days Until Poisoned Plants StabilizePHONE SCREEN · Seen Oct 2026
- Capture Surrounded Regions with Union-FindPHONE SCREEN · Seen Oct 2026
- Maintain a Consistent-Hashing RingPHONE SCREEN · Seen Oct 2026
- Count Nodes in a ChainPHONE SCREEN · Seen Oct 2026
- Run-Length DecodingPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Word Search IIAmazon · ONSITE INTERVIEW
- Word SearchBloomberg LP · OA · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Word SearchCognitiv · PHONE SCREEN
- Find a Word in a Letter GridAdobe · PHONE SCREENAdobe interview questions
- Word SearchWhatNot · PHONE SCREENWhatNot interview questions
- Adjacent-Key Lock PatternsC3.ai · PHONE SCREENC3.ai interview questions
- Enumerate Top-to-Bottom Grid PathsGoogle · ONSITE INTERVIEWGoogle interview questions
- Cave AdvantureMeta · OAMeta interview questions
- Word SearchMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Enumerate Character Paths to a MarkerTesla · ONSITE INTERVIEWTesla interview questions
Apple interview experiences
- Apple SWE Phone Screen: Subarray Products: 1 Experience
- Apple New Grad SWE Java, Coding and Manager Rounds: 1 Experience
- Apple AI Coding and Related Interviews: 17 Experiences
- Apple India SWE New Grad Interviews: 5 Experiences
- Apple New Grad SWE Phone Screens: 12 Experiences (Part 3 of 3)
- Apple New Grad SWE and Embedded: 16 Experiences (Part 2 of 3)