desc.html 1.4 KB
Newer Older
每日一练社区's avatar
每日一练社区 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
<p>给出一个单词列表,其中每个单词都由小写英文字母组成。</p>

<p>如果我们可以在&nbsp;<code>word1</code>&nbsp;的任何地方添加一个字母使其变成&nbsp;<code>word2</code>,那么我们认为&nbsp;<code>word1</code>&nbsp;&nbsp;<code>word2</code>&nbsp;的前身。例如,<code>&quot;abc&quot;</code>&nbsp;&nbsp;<code>&quot;abac&quot;</code>&nbsp;的前身。</p>

<p><strong>词链</strong>是单词&nbsp;<code>[word_1, word_2, ..., word_k]</code>&nbsp;组成的序列,<code>k &gt;= 1</code>,其中&nbsp;<code>word_1</code>&nbsp;&nbsp;<code>word_2</code>&nbsp;的前身,<code>word_2</code>&nbsp;&nbsp;<code>word_3</code>&nbsp;的前身,依此类推。</p>

<p>从给定单词列表 <code>words</code> 中选择单词组成词链,返回词链的最长可能长度。<br>
&nbsp;</p>

<p><strong>示例:</strong></p>

<pre><strong>输入:</strong>[&quot;a&quot;,&quot;b&quot;,&quot;ba&quot;,&quot;bca&quot;,&quot;bda&quot;,&quot;bdca&quot;]
<strong>输出:</strong>4
<strong>解释:</strong>最长单词链之一为 &quot;a&quot;,&quot;ba&quot;,&quot;bda&quot;,&quot;bdca&quot;
</pre>

<p>&nbsp;</p>

<p><strong>提示:</strong></p>

<ol>
	<li><code>1 &lt;= words.length &lt;= 1000</code></li>
	<li><code>1 &lt;= words[i].length &lt;= 16</code></li>
	<li><code>words[i]</code>&nbsp;仅由小写英文字母组成。</li>
</ol>

<p>&nbsp;</p>