mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-21 21:16:45 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个下标从 <strong>0</strong> 开始的整数数组 <code>nums</code> 和一个整数 <code>pivot</code> 。请你将 <code>nums</code> 重新排列,使得以下条件均成立:</p>\n\n<ul>\n\t<li>所有小于 <code>pivot</code> 的元素都出现在所有大于 <code>pivot</code> 的元素 <strong>之前</strong> 。</li>\n\t<li>所有等于 <code>pivot</code> 的元素都出现在小于和大于 <code>pivot</code> 的元素 <strong>中间</strong> 。</li>\n\t<li>小于 <code>pivot</code> 的元素之间和大于 <code>pivot</code> 的元素之间的 <strong>相对顺序</strong> 不发生改变。\n\t<ul>\n\t\t<li>更正式的,考虑每一对 <code>p<sub>i</sub></code>,<code>p<sub>j</sub></code> ,<code>p<sub>i</sub></code> 是初始时位置 <code>i</code> 元素的新位置,<code>p<sub>j</sub></code> 是初始时位置 <code>j</code> 元素的新位置。对于小于 <code>pivot</code> 的元素,如果 <code>i < j</code> 且 <code>nums[i] < pivot</code> 和 <code>nums[j] < pivot</code> 都成立,那么 <code>p<sub>i</sub> < p<sub>j</sub></code> 也成立。类似的,对于大于 <code>pivot</code> 的元素,如果 <code>i < j</code> 且 <code>nums[i] > pivot</code> 和 <code>nums[j] > pivot</code> 都成立,那么 <code>p<sub>i</sub> < p<sub>j</sub></code> 。</li>\n\t</ul>\n\t</li>\n</ul>\n\n<p>请你返回重新排列 <code>nums</code> 数组后的结果数组。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre><b>输入:</b>nums = [9,12,5,10,14,3,10], pivot = 10\n<b>输出:</b>[9,5,3,10,10,12,14]\n<b>解释:</b>\n元素 9 ,5 和 3 小于 pivot ,所以它们在数组的最左边。\n元素 12 和 14 大于 pivot ,所以它们在数组的最右边。\n小于 pivot 的元素的相对位置和大于 pivot 的元素的相对位置分别为 [9, 5, 3] 和 [12, 14] ,它们在结果数组中的相对顺序需要保留。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre><b>输入:</b>nums = [-3,4,3,2], pivot = 2\n<b>输出:</b>[-3,2,4,3]\n<b>解释:</b>\n元素 -3 小于 pivot ,所以在数组的最左边。\n元素 4 和 3 大于 pivot ,所以它们在数组的最右边。\n小于 pivot 的元素的相对位置和大于 pivot 的元素的相对位置分别为 [-3] 和 [4, 3] ,它们在结果数组中的相对顺序需要保留。\n</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>-10<sup>6</sup> <= nums[i] <= 10<sup>6</sup></code></li>\n\t<li><code>pivot</code> 等于 <code>nums</code> 中的一个元素。</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 9,
|
||||
"likes": 10,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -149,7 +149,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"4.9K\", \"totalSubmission\": \"5.7K\", \"totalAcceptedRaw\": 4924, \"totalSubmissionRaw\": 5698, \"acRate\": \"86.4%\"}",
|
||||
"stats": "{\"totalAccepted\": \"5.3K\", \"totalSubmission\": \"6.2K\", \"totalAcceptedRaw\": 5324, \"totalSubmissionRaw\": 6240, \"acRate\": \"85.3%\"}",
|
||||
"hints": [
|
||||
"Could you put the elements smaller than the pivot and greater than the pivot in a separate list as in the sequence that they occur?",
|
||||
"With the separate lists generated, could you then generate the result?"
|
||||
|
Reference in New Issue
Block a user