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>给你一个下标从 <strong>0</strong> 开始的字符串 <code>s</code> ,以及一个下标从 <strong>0</strong> 开始的整数数组 <code>spaces</code> 。</p>\n\n<p>数组 <code>spaces</code> 描述原字符串中需要添加空格的下标。每个空格都应该插入到给定索引处的字符值 <strong>之前</strong> 。</p>\n\n<ul>\n\t<li>例如,<code>s = \"EnjoyYourCoffee\"</code> 且 <code>spaces = [5, 9]</code> ,那么我们需要在 <code>'Y'</code> 和 <code>'C'</code> 之前添加空格,这两个字符分别位于下标 <code>5</code> 和下标 <code>9</code> 。因此,最终得到 <code>\"Enjoy <em><strong>Y</strong></em>our <em><strong>C</strong></em>offee\"</code> 。</li>\n</ul>\n\n<p>请你添加空格,并返回修改后的字符串<em>。</em></p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>s = \"LeetcodeHelpsMeLearn\", spaces = [8,13,15]\n<strong>输出:</strong>\"Leetcode Helps Me Learn\"\n<strong>解释:</strong>\n下标 8、13 和 15 对应 \"Leetcode<em><strong>H</strong></em>elps<em><strong>M</strong></em>e<em><strong>L</strong></em>earn\" 中加粗斜体字符。\n接着在这些字符前添加空格。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>s = \"icodeinpython\", spaces = [1,5,7,9]\n<strong>输出:</strong>\"i code in py thon\"\n<strong>解释:</strong>\n下标 1、5、7 和 9 对应 \"i<em><strong>c</strong></em>ode<em><strong>i</strong></em>n<em><strong>p</strong></em>y<em><strong>t</strong></em>hon\" 中加粗斜体字符。\n接着在这些字符前添加空格。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<strong>输入:</strong>s = \"spacing\", spaces = [0,1,2,3,4,5,6]\n<strong>输出:</strong>\" s p a c i n g\"\n<strong>解释:</strong>\n字符串的第一个字符前可以添加空格。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= s.length <= 3 * 10<sup>5</sup></code></li>\n\t<li><code>s</code> 仅由大小写英文字母组成</li>\n\t<li><code>1 <= spaces.length <= 3 * 10<sup>5</sup></code></li>\n\t<li><code>0 <= spaces[i] <= s.length - 1</code></li>\n\t<li><code>spaces</code> 中的所有值 <strong>严格递增</strong></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 11,
|
||||
"likes": 12,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -149,7 +149,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"6.9K\", \"totalSubmission\": \"11.3K\", \"totalAcceptedRaw\": 6888, \"totalSubmissionRaw\": 11320, \"acRate\": \"60.8%\"}",
|
||||
"stats": "{\"totalAccepted\": \"7.3K\", \"totalSubmission\": \"12K\", \"totalAcceptedRaw\": 7346, \"totalSubmissionRaw\": 12022, \"acRate\": \"61.1%\"}",
|
||||
"hints": [
|
||||
"Create a new string, initially empty, as the modified string. Iterate through the original string and append each character of the original string to the new string. However, each time you reach a character that requires a space before it, append a space before appending the character.",
|
||||
"Since the array of indices for the space locations is sorted, use a pointer to keep track of the next index to place a space. Only increment the pointer once a space has been appended.",
|
||||
|
Reference in New Issue
Block a user