mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-02 14:12:17 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p><a href=\"https://baike.baidu.com/item/%E8%A1%8C%E7%A8%8B%E9%95%BF%E5%BA%A6%E7%BC%96%E7%A0%81/2931940?fr=aladdin\" target=\"_blank\">行程长度编码</a> 是一种常用的字符串压缩方法,它将连续的相同字符(重复 2 次或更多次)替换为字符和表示字符计数的数字(行程长度)。例如,用此方法压缩字符串 <code>"aabccc"</code> ,将 <code>"aa"</code> 替换为 <code>"a2"</code> ,<code>"ccc"</code> 替换为` <code>"c3"</code> 。因此压缩后的字符串变为 <code>"a2bc3"</code> 。</p>\n\n<p>注意,本问题中,压缩时没有在单个字符后附加计数 <code>'1'</code> 。</p>\n\n<p>给你一个字符串 <code>s</code> 和一个整数 <code>k</code> 。你需要从字符串 <code>s</code> 中删除最多 <code>k</code> 个字符,以使 <code>s</code> 的行程长度编码长度最小。</p>\n\n<p>请你返回删除最多 <code>k</code> 个字符后,<code>s</code> <strong>行程长度编码的最小长度</strong> 。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre><strong>输入:</strong>s = "aaabcccd", k = 2\n<strong>输出:</strong>4\n<strong>解释:</strong>在不删除任何内容的情况下,压缩后的字符串是 "a3bc3d" ,长度为 6 。最优的方案是删除 'b' 和 'd',这样一来,压缩后的字符串为 "a3c3" ,长度是 4 。</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre><strong>输入:</strong>s = "aabbaa", k = 2\n<strong>输出:</strong>2\n<strong>解释:</strong>如果删去两个 'b' 字符,那么压缩后的字符串是长度为 2 的 "a4" 。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre><strong>输入:</strong>s = "aaaaaaaaaaa", k = 0\n<strong>输出:</strong>3\n<strong>解释:</strong>由于 k 等于 0 ,不能删去任何字符。压缩后的字符串是 "a11" ,长度为 3 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= s.length <= 100</code></li>\n\t<li><code>0 <= k <= s.length</code></li>\n\t<li><code>s</code> 仅包含小写英文字母</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 79,
|
||||
"likes": 80,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"2.2K\", \"totalSubmission\": \"6.4K\", \"totalAcceptedRaw\": 2250, \"totalSubmissionRaw\": 6361, \"acRate\": \"35.4%\"}",
|
||||
"stats": "{\"totalAccepted\": \"2.3K\", \"totalSubmission\": \"6.4K\", \"totalAcceptedRaw\": 2257, \"totalSubmissionRaw\": 6370, \"acRate\": \"35.4%\"}",
|
||||
"hints": [
|
||||
"Use dynamic programming.",
|
||||
"The state of the DP can be the current index and the remaining characters to delete.",
|
||||
|
Reference in New Issue
Block a user