Problem
Meta wants to scan a character grid for valid keywords that may appear in surfaces like Messenger game boards. Given a 2D board of lowercase letters and a list of lowercase words, return all words that can be formed by traversing adjacent cells.
A word can be constructed from letters of sequentially adjacent cells, where adjacency is horizontal or vertical. The same cell may not be used more than once in a single word.
Formal Specification
Implement a function that takes:
board: a list ofmrows, each row a list ofnlowercase characterswords: a list of distinct lowercase strings
Return a list of all words from words that appear in the board. The output may be in any order.
Constraints
- 1 <= board.length <= 12
- 1 <= board[0].length <= 12
- 1 <= words.length <= 3 * 10^4
- 1 <= words[i].length <= 10
- board[i][j] consists of lowercase English letters
- words[i] consists of lowercase English letters
- All words in words are unique
Function Signature
def find_words(board, words):
You are practicing as a guest. Sign up free to run your code against the sample data. Your draft stays right here.


