2022-03-27 18:35:17 +08:00
< p > Given an < code > m x n< / code > < code > board< / code > of characters and a list of strings < code > words< / code > , return < em > all words on the board< / em > .< / p >
< p > Each word must be constructed from letters of sequentially adjacent cells, where < strong > adjacent cells< / strong > are horizontally or vertically neighboring. The same letter cell may not be used more than once in a word.< / p >
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
2022-03-27 18:35:17 +08:00
< img alt = "" src = "https://assets.leetcode.com/uploads/2020/11/07/search1.jpg" style = "width: 322px; height: 322px;" / >
< pre >
< strong > Input:< / strong > board = [[" o" ," a" ," a" ," n" ],[" e" ," t" ," a" ," e" ],[" i" ," h" ," k" ," r" ],[" i" ," f" ," l" ," v" ]], words = [" oath" ," pea" ," eat" ," rain" ]
< strong > Output:< / strong > [" eat" ," oath" ]
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 2:< / strong > < / p >
2022-03-27 18:35:17 +08:00
< img alt = "" src = "https://assets.leetcode.com/uploads/2020/11/07/search2.jpg" style = "width: 162px; height: 162px;" / >
< pre >
< strong > Input:< / strong > board = [[" a" ," b" ],[" c" ," d" ]], words = [" abcb" ]
< strong > Output:< / strong > []
< / pre >
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > m == board.length< / code > < / li >
< li > < code > n == board[i].length< / code > < / li >
< li > < code > 1 < = m, n < = 12< / code > < / li >
< li > < code > board[i][j]< / code > is a lowercase English letter.< / li >
< li > < code > 1 < = words.length < = 3 * 10< sup > 4< / sup > < / code > < / li >
< li > < code > 1 < = words[i].length < = 10< / code > < / li >
< li > < code > words[i]< / code > consists of lowercase English letters.< / li >
< li > All the strings of < code > words< / code > are unique.< / li >
< / ul >