1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-12-18 18:14:59 +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>chars</code> ,请使用下述算法压缩:</p>\n\n<p>从一个空字符串 <code>s</code> 开始。对于 <code>chars</code> 中的每组 <strong>连续重复字符</strong> </p>\n\n<ul>\n\t<li>如果这一组长度为 <code>1</code> ,则将字符追加到 <code>s</code> 中。</li>\n\t<li>否则,需要向 <code>s</code> 追加字符,后跟这一组的长度。</li>\n</ul>\n\n<p>压缩后得到的字符串 <code>s</code> <strong>不应该直接返回</strong> ,需要转储到字符数组 <code>chars</code> 中。需要注意的是,如果组长度为 <code>10</code> 或 <code>10</code> 以上,则在 <code>chars</code> 数组中会被拆分为多个字符。</p>\n\n<p>请在 <strong>修改完输入数组后</strong> ,返回该数组的新长度。</p>\n\n<p>你必须设计并实现一个只使用常量额外空间的算法来解决此问题。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>chars = [\"a\",\"a\",\"b\",\"b\",\"c\",\"c\",\"c\"]\n<strong>输出:</strong>返回 6 ,输入数组的前 6 个字符应该是:[\"a\",\"2\",\"b\",\"2\",\"c\",\"3\"]\n<strong>解释:</strong>\"aa\" 被 \"a2\" 替代。\"bb\" 被 \"b2\" 替代。\"ccc\" 被 \"c3\" 替代。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>chars = [\"a\"]\n<strong>输出:</strong>返回 1 ,输入数组的前 1 个字符应该是:[\"a\"]\n<strong>解释:</strong>唯一的组是“a”它保持未压缩因为它是一个字符。\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre>\n<strong>输入:</strong>chars = [\"a\",\"b\",\"b\",\"b\",\"b\",\"b\",\"b\",\"b\",\"b\",\"b\",\"b\",\"b\",\"b\"]\n<strong>输出:</strong>返回 4 ,输入数组的前 4 个字符应该是:[\"a\",\"b\",\"1\",\"2\"]。\n<strong>解释:</strong>由于字符 \"a\" 不重复,所以不会被压缩。\"bbbbbbbbbbbb\" 被 “b12” 替代。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= chars.length &lt;= 2000</code></li>\n\t<li><code>chars[i]</code> 可以是小写英文字母、大写英文字母、数字或符号</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 292,
"likes": 294,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[{\"title\": \"Count and Say\", \"titleSlug\": \"count-and-say\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u5916\\u89c2\\u6570\\u5217\"}, {\"title\": \"Encode and Decode Strings\", \"titleSlug\": \"encode-and-decode-strings\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u5b57\\u7b26\\u4e32\\u7684\\u7f16\\u7801\\u4e0e\\u89e3\\u7801\"}, {\"title\": \"Design Compressed String Iterator\", \"titleSlug\": \"design-compressed-string-iterator\", \"difficulty\": \"Easy\", \"translatedTitle\": \"\\u8fed\\u4ee3\\u538b\\u7f29\\u5b57\\u7b26\\u4e32\"}]",
@@ -131,7 +131,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"62.8K\", \"totalSubmission\": \"131.4K\", \"totalAcceptedRaw\": 62780, \"totalSubmissionRaw\": 131433, \"acRate\": \"47.8%\"}",
"stats": "{\"totalAccepted\": \"63.8K\", \"totalSubmission\": \"133.7K\", \"totalAcceptedRaw\": 63826, \"totalSubmissionRaw\": 133669, \"acRate\": \"47.7%\"}",
"hints": [
"How do you know if you are at the end of a consecutive group of characters?"
],