212. Word Search II Hard

@problem@discussion
#Array#String#Backtracking#Trie#Matrix



1/**
2 * [212] Word Search II
3 *
4 * Given an m x n board of characters and a list of strings words, return all words on the board.
5 * 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.
6 *  
7 * Example 1:
8 * <img alt="" src="https://assets.leetcode.com/uploads/2020/11/07/search1.jpg" style="width: 322px; height: 322px;" />
9 * Input: board = [["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l","v"]], words = ["oath","pea","eat","rain"]
10 * Output: ["eat","oath"]
11 * 
12 * Example 2:
13 * <img alt="" src="https://assets.leetcode.com/uploads/2020/11/07/search2.jpg" style="width: 162px; height: 162px;" />
14 * Input: board = [["a","b"],["c","d"]], words = ["abcb"]
15 * Output: []
16 * 
17 *  
18 * Constraints:
19 * 
20 * 	m == board.length
21 * 	n == board[i].length
22 * 	1 <= m, n <= 12
23 * 	board[i][j] is a lowercase English letter.
24 * 	1 <= words.length <= 3 * 10^4
25 * 	1 <= words[i].length <= 10
26 * 	words[i] consists of lowercase English letters.
27 * 	All the strings of words are unique.
28 * 
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/word-search-ii/
33// discuss: https://leetcode.com/problems/word-search-ii/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38    pub fn find_words(board: Vec<Vec<char>>, words: Vec<String>) -> Vec<String> {
39        vec![]
40    }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_212() {
51    }
52}
53


Back
© 2025 bowen.ge All Rights Reserved.