1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-25 23:08: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><strong>小写字符 </strong>的 <strong>数值</strong> 是它在字母表中的位置(从 <code>1</code> 开始),因此 <code>a</code> 的数值为 <code>1</code> <code>b</code> 的数值为 <code>2</code> <code>c</code> 的数值为 <code>3</code> ,以此类推。</p>\n\n<p>字符串由若干小写字符组成,<strong>字符串的数值</strong> 为各字符的数值之和。例如,字符串 <code>\"abe\"</code> 的数值等于 <code>1 + 2 + 5 = 8</code> 。</p>\n\n<p>给你两个整数 <code>n</code> 和 <code>k</code> 。返回 <strong>长度</strong> 等于 <code>n</code> 且 <strong>数值</strong> 等于 <code>k</code> 的 <strong>字典序最小</strong> 的字符串。</p>\n\n<p>注意,如果字符串 <code>x</code> 在字典排序中位于 <code>y</code> 之前,就认为 <code>x</code> 字典序比 <code>y</code> 小,有以下两种情况:</p>\n\n<ul>\n\t<li><code>x</code> 是 <code>y</code> 的一个前缀;</li>\n\t<li>如果 <code>i</code> 是 <code>x[i] != y[i]</code> 的第一个位置,且 <code>x[i]</code> 在字母表中的位置比 <code>y[i]</code> 靠前。</li>\n</ul>\n\n<p> </p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 3, k = 27\n<strong>输出:</strong>\"aay\"\n<strong>解释:</strong>字符串的数值为 1 + 1 + 25 = 27它是数值满足要求且长度等于 3 字典序最小的字符串。</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 5, k = 73\n<strong>输出:</strong>\"aaszz\"\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= n <= 10<sup>5</sup></code></li>\n\t<li><code>n <= k <= 26 * n</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 33,
"likes": 34,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -143,7 +143,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"8.7K\", \"totalSubmission\": \"15.2K\", \"totalAcceptedRaw\": 8712, \"totalSubmissionRaw\": 15168, \"acRate\": \"57.4%\"}",
"stats": "{\"totalAccepted\": \"8.9K\", \"totalSubmission\": \"15.5K\", \"totalAcceptedRaw\": 8894, \"totalSubmissionRaw\": 15495, \"acRate\": \"57.4%\"}",
"hints": [
"Think greedily.",
"If you build the string from the end to the beginning, it will always be optimal to put the highest possible character at the current index."