|
| 1 | +<h2>79. Word Search</h2><h3>Medium</h3><hr><div><p>Given an <code>m x n</code> grid of characters <code>board</code> and a string <code>word</code>, return <code>true</code> <em>if</em> <code>word</code> <em>exists in the grid</em>.</p> |
| 2 | + |
| 3 | +<p>The word can 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.</p> |
| 4 | + |
| 5 | +<p> </p> |
| 6 | +<p><strong>Example 1:</strong></p> |
| 7 | +<img alt="" src="https://assets.leetcode.com/uploads/2020/11/04/word2.jpg" style="width: 322px; height: 242px;"> |
| 8 | +<pre><strong>Input:</strong> board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCCED" |
| 9 | +<strong>Output:</strong> true |
| 10 | +</pre> |
| 11 | + |
| 12 | +<p><strong>Example 2:</strong></p> |
| 13 | +<img alt="" src="https://assets.leetcode.com/uploads/2020/11/04/word-1.jpg" style="width: 322px; height: 242px;"> |
| 14 | +<pre><strong>Input:</strong> board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "SEE" |
| 15 | +<strong>Output:</strong> true |
| 16 | +</pre> |
| 17 | + |
| 18 | +<p><strong>Example 3:</strong></p> |
| 19 | +<img alt="" src="https://assets.leetcode.com/uploads/2020/10/15/word3.jpg" style="width: 322px; height: 242px;"> |
| 20 | +<pre><strong>Input:</strong> board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCB" |
| 21 | +<strong>Output:</strong> false |
| 22 | +</pre> |
| 23 | + |
| 24 | +<p> </p> |
| 25 | +<p><strong>Constraints:</strong></p> |
| 26 | + |
| 27 | +<ul> |
| 28 | + <li><code>m == board.length</code></li> |
| 29 | + <li><code>n = board[i].length</code></li> |
| 30 | + <li><code>1 <= m, n <= 6</code></li> |
| 31 | + <li><code>1 <= word.length <= 15</code></li> |
| 32 | + <li><code>board</code> and <code>word</code> consists of only lowercase and uppercase English letters.</li> |
| 33 | +</ul> |
| 34 | + |
| 35 | +<p> </p> |
| 36 | +<p><strong>Follow up:</strong> Could you use search pruning to make your solution faster with a larger <code>board</code>?</p> |
| 37 | +</div> |
0 commit comments