mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-22 21:46:46 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个数组,将数组中的元素向右轮转 <code>k</code><em> </em>个位置,其中 <code>k</code><em> </em>是非负数。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong> nums = [1,2,3,4,5,6,7], k = 3\n<strong>输出:</strong> <code>[5,6,7,1,2,3,4]</code>\n<strong>解释:</strong>\n向右轮转 1 步: <code>[7,1,2,3,4,5,6]</code>\n向右轮转 2 步: <code>[6,7,1,2,3,4,5]\n</code>向右轮转 3 步: <code>[5,6,7,1,2,3,4]</code>\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>nums = [-1,-100,3,99], k = 2\n<strong>输出:</strong>[3,99,-1,-100]\n<strong>解释:</strong> \n向右轮转 1 步: [99,-1,-100,3]\n向右轮转 2 步: [3,99,-1,-100]</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>\n\t<li><code>-2<sup>31</sup> <= nums[i] <= 2<sup>31</sup> - 1</code></li>\n\t<li><code>0 <= k <= 10<sup>5</sup></code></li>\n</ul>\n\n<p> </p>\n\n<p><strong>进阶:</strong></p>\n\n<ul>\n\t<li>尽可能想出更多的解决方案,至少有 <strong>三种</strong> 不同的方法可以解决这个问题。</li>\n\t<li>你可以使用空间复杂度为 <code>O(1)</code> 的 <strong>原地 </strong>算法解决这个问题吗?</li>\n</ul>\n\n<ul>\n</ul>\n\n<ul>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 1415,
|
||||
"likes": 1453,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Rotate List\", \"titleSlug\": \"rotate-list\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u65cb\\u8f6c\\u94fe\\u8868\"}, {\"title\": \"Reverse Words in a String II\", \"titleSlug\": \"reverse-words-in-a-string-ii\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u7ffb\\u8f6c\\u5b57\\u7b26\\u4e32\\u91cc\\u7684\\u5355\\u8bcd II\"}]",
|
||||
@@ -137,7 +137,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"465.3K\", \"totalSubmission\": \"1M\", \"totalAcceptedRaw\": 465253, \"totalSubmissionRaw\": 1048366, \"acRate\": \"44.4%\"}",
|
||||
"stats": "{\"totalAccepted\": \"484.5K\", \"totalSubmission\": \"1.1M\", \"totalAcceptedRaw\": 484507, \"totalSubmissionRaw\": 1092732, \"acRate\": \"44.3%\"}",
|
||||
"hints": [
|
||||
"The easiest solution would use additional memory and that is perfectly fine.",
|
||||
"The actual trick comes when trying to solve this problem without using any additional memory. This means you need to use the original array somehow to move the elements around. Now, we can place each element in its original location and shift all the elements around it to adjust as that would be too costly and most likely will time out on larger input arrays.",
|
||||
|
Reference in New Issue
Block a user