1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-25 06:48:57 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给出一个单词数组&nbsp;<code>words</code>&nbsp;,其中每个单词都由小写英文字母组成。</p>\n\n<p>如果我们可以&nbsp;<strong>不改变其他字符的顺序&nbsp;</strong>,在 <code>word<sub>A</sub></code>&nbsp;的任何地方添加 <strong>恰好一个</strong> 字母使其变成&nbsp;<code>word<sub>B</sub></code>&nbsp;,那么我们认为&nbsp;<code>word<sub>A</sub></code>&nbsp;是&nbsp;<code>word<sub>B</sub></code>&nbsp;的 <strong>前身</strong> 。</p>\n\n<ul>\n\t<li>例如,<code>\"abc\"</code>&nbsp;是&nbsp;<code>\"abac\"</code>&nbsp;的 <strong>前身</strong>&nbsp;,而&nbsp;<code>\"cba\"</code>&nbsp;不是&nbsp;<code>\"bcad\"</code>&nbsp;的 <strong>前身</strong></li>\n</ul>\n\n<p><strong>词链</strong>是单词&nbsp;<code>[word_1, word_2, ..., word_k]</code>&nbsp;组成的序列,<code>k &gt;= 1</code>,其中&nbsp;<code>word<sub>1</sub></code>&nbsp;是&nbsp;<code>word<sub>2</sub></code>&nbsp;的前身,<code>word<sub>2</sub></code>&nbsp;是&nbsp;<code>word<sub>3</sub></code>&nbsp;的前身,依此类推。一个单词通常是 <code>k == 1</code> 的 <strong>单词链</strong>&nbsp;。</p>\n\n<p>从给定单词列表 <code>words</code> 中选择单词组成词链,返回 词链的&nbsp;<strong>最长可能长度</strong> 。<br />\n&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>words = [\"a\",\"b\",\"ba\",\"bca\",\"bda\",\"bdca\"]\n<strong>输出:</strong>4\n<strong>解释:</strong>最长单词链之一为 [\"a\",\"<u>b</u>a\",\"b<u>d</u>a\",\"bd<u>c</u>a\"]\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<b>输入:</b>words = [\"xbc\",\"pcxbcf\",\"xb\",\"cxbc\",\"pcxbc\"]\n<b>输出:</b>5\n<b>解释:</b>所有的单词都可以放入单词链 [\"xb\", \"xb<u>c</u>\", \"<u>c</u>xbc\", \"<u>p</u>cxbc\", \"pcxbc<u>f</u>\"].\n</pre>\n\n<p><strong>示例&nbsp;3:</strong></p>\n\n<pre>\n<b>输入:</b>words = [\"abcd\",\"dbqca\"]\n<strong>输出:</strong>1\n<b>解释:</b>字链[\"abcd\"]是最长的字链之一。\n[\"abcd\"\"dbqca\"]不是一个有效的单词链,因为字母的顺序被改变了。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= words.length &lt;= 1000</code></li>\n\t<li><code>1 &lt;= words[i].length &lt;= 16</code></li>\n\t<li><code>words[i]</code>&nbsp;仅由小写英文字母组成。</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 167,
"likes": 171,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -161,7 +161,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"12.5K\", \"totalSubmission\": \"26.7K\", \"totalAcceptedRaw\": 12528, \"totalSubmissionRaw\": 26658, \"acRate\": \"47.0%\"}",
"stats": "{\"totalAccepted\": \"13K\", \"totalSubmission\": \"27.6K\", \"totalAcceptedRaw\": 12991, \"totalSubmissionRaw\": 27613, \"acRate\": \"47.0%\"}",
"hints": [
"Instead of adding a character, try deleting a character to form a chain in reverse.",
"For each word in order of length, for each word2 which is word with one character removed, length[word2] = max(length[word2], length[word] + 1)."