1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-22 05:26:46 +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>给定一个正整数 <code>n</code> ,输出外观数列的第 <code>n</code> 项。</p>\n\n<p>「外观数列」是一个整数序列,从数字 1 开始,序列中的每一项都是对前一项的描述。</p>\n\n<p>你可以将其视作是由递归公式定义的数字字符串序列:</p>\n\n<ul>\n\t<li><code>countAndSay(1) = \"1\"</code></li>\n\t<li><code>countAndSay(n)</code> 是对 <code>countAndSay(n-1)</code> 的描述,然后转换成另一个数字字符串。</li>\n</ul>\n\n<p>前五项如下:</p>\n\n<pre>\n1. 1\n2. 11\n3. 21\n4. 1211\n5. 111221\n第一项是数字 1 \n描述前一项这个数是 <code>1</code> 即 “ 一 个 1 ”,记作 <code>\"11\"\n</code>描述前一项,这个数是 <code>11</code> 即 “ 二 个 1 ” ,记作 <code>\"21\"\n</code>描述前一项,这个数是 <code>21</code> 即 “ 一 个 2 + 一 个 1 ” ,记作 \"<code>1211\"\n</code>描述前一项,这个数是 <code>1211</code> 即 “ 一 个 1 + 一 个 2 + 二 个 1 ” ,记作 \"<code>111221\"</code>\n</pre>\n\n<p>要 <strong>描述</strong> 一个数字字符串,首先要将字符串分割为 <strong>最小</strong> 数量的组,每个组都由连续的最多 <strong>相同字符</strong> 组成。然后对于每个组,先描述字符的数量,然后描述字符,形成一个描述组。要将描述转换为数字字符串,先将每组中的字符数量用数字替换,再将所有描述组连接起来。</p>\n\n<p>例如,数字字符串 <code>\"3322251\"</code> 的描述如下图:</p>\n<img alt=\"\" src=\"https://pic.leetcode-cn.com/1629874763-TGmKUh-image.png\" style=\"width: 581px; height: 172px;\" />\n<ul>\n</ul>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 1\n<strong>输出:</strong>\"1\"\n<strong>解释:</strong>这是一个基本样例。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 4\n<strong>输出:</strong>\"1211\"\n<strong>解释:</strong>\ncountAndSay(1) = \"1\"\ncountAndSay(2) = 读 \"1\" = 一 个 1 = \"11\"\ncountAndSay(3) = 读 \"11\" = 二 个 1 = \"21\"\ncountAndSay(4) = 读 \"21\" = 一 个 2 + 一 个 1 = \"12\" + \"11\" = \"1211\"\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= n &lt;= 30</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 883,
"likes": 896,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[{\"title\": \"Encode and Decode Strings\", \"titleSlug\": \"encode-and-decode-strings\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u5b57\\u7b26\\u4e32\\u7684\\u7f16\\u7801\\u4e0e\\u89e3\\u7801\"}, {\"title\": \"String Compression\", \"titleSlug\": \"string-compression\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u538b\\u7f29\\u5b57\\u7b26\\u4e32\"}]",
@@ -137,7 +137,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"272.5K\", \"totalSubmission\": \"455.2K\", \"totalAcceptedRaw\": 272486, \"totalSubmissionRaw\": 455193, \"acRate\": \"59.9%\"}",
"stats": "{\"totalAccepted\": \"278.6K\", \"totalSubmission\": \"465K\", \"totalAcceptedRaw\": 278642, \"totalSubmissionRaw\": 464961, \"acRate\": \"59.9%\"}",
"hints": [
"The following are the terms from n=1 to n=10 of the count-and-say sequence:\r\n<pre>\r\n 1. 1\r\n 2. 11\r\n 3. 21\r\n 4. 1211\r\n 5. 111221 \r\n 6. 312211\r\n 7. 13112221\r\n 8. 1113213211\r\n 9. 31131211131221\r\n10. 13211311123113112211\r\n</pre>",
"To generate the <i>n</i><sup>th</sup> term, just <i>count and say</i> the <i>n</i>-1<sup>th</sup> term."