mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
33 lines
1.8 KiB
HTML
33 lines
1.8 KiB
HTML
|
<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>
|
||
|
<p><strong>Example 1:</strong></p>
|
||
|
<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>
|
||
|
|
||
|
<p><strong>Example 2:</strong></p>
|
||
|
<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>
|