LeetCode 212, Hard. Topics: Array, String, Backtracking, Trie, Matrix. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 12 parametrized pytest cases, and a playground notebook:
Problem
Given an m x n board of characters and a list of strings words, return all words on the board.
Each word must be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once in a word.
Examples
Explanation: The words “eat” and “oath” can be found on the board.
Explanation: The word “abcb” cannot be found on the board.
Constraints
- m == board.length
- n == board[i].length
- 1 <= m, n <= 12
- board[i][j] is a lowercase English letter.
- 1 <= words.length <= 3 * 10^4
- 1 <= words[i].length <= 10
- words[i] consists of lowercase English letters.
- All the strings of words are unique.
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
Grind, Blind 75, NeetCode 150, NeetCode 250, NeetCode All, AlgoMaster 75. Last modified on September 7, 2026