mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-22 05:26:46 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个下标从 <strong>0</strong> 开始且长度为 <code>n</code> 的整数数组 <code>nums</code> 。<strong>分割</strong> 数组 <code>nums</code> 的方案数定义为符合以下两个条件的 <code>pivot</code> 数目:</p>\n\n<ul>\n\t<li><code>1 <= pivot < n</code></li>\n\t<li><code>nums[0] + nums[1] + ... + nums[pivot - 1] == nums[pivot] + nums[pivot + 1] + ... + nums[n - 1]</code></li>\n</ul>\n\n<p>同时给你一个整数 <code>k</code> 。你可以将 <code>nums</code> 中 <strong>一个</strong> 元素变为 <code>k</code> 或 <strong>不改变</strong> 数组。</p>\n\n<p>请你返回在 <strong>至多</strong> 改变一个元素的前提下,<strong>最多</strong> 有多少种方法 <strong>分割</strong> <code>nums</code> 使得上述两个条件都满足。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre><b>输入:</b>nums = [2,-1,2], k = 3\n<b>输出:</b>1\n<b>解释:</b>一个最优的方案是将 nums[0] 改为 k 。数组变为 [<em><strong>3</strong></em>,-1,2] 。\n有一种方法分割数组:\n- pivot = 2 ,我们有分割 [3,-1 | 2]:3 + -1 == 2 。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre><b>输入:</b>nums = [0,0,0], k = 1\n<b>输出:</b>2\n<b>解释:</b>一个最优的方案是不改动数组。\n有两种方法分割数组:\n- pivot = 1 ,我们有分割 [0 | 0,0]:0 == 0 + 0 。\n- pivot = 2 ,我们有分割 [0,0 | 0]: 0 + 0 == 0 。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre><b>输入:</b>nums = [22,4,-25,-20,-15,15,-16,7,19,-10,0,-13,-14], k = -33\n<b>输出:</b>4\n<b>解释:</b>一个最优的方案是将 nums[2] 改为 k 。数组变为 [22,4,<em><strong>-33</strong></em>,-20,-15,15,-16,7,19,-10,0,-13,-14] 。\n有四种方法分割数组。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>n == nums.length</code></li>\n\t<li><code>2 <= n <= 10<sup>5</sup></code></li>\n\t<li><code>-10<sup>5</sup> <= k, nums[i] <= 10<sup>5</sup></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 23,
|
||||
"likes": 26,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -161,7 +161,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"1.6K\", \"totalSubmission\": \"5.8K\", \"totalAcceptedRaw\": 1602, \"totalSubmissionRaw\": 5801, \"acRate\": \"27.6%\"}",
|
||||
"stats": "{\"totalAccepted\": \"1.7K\", \"totalSubmission\": \"6K\", \"totalAcceptedRaw\": 1662, \"totalSubmissionRaw\": 5971, \"acRate\": \"27.8%\"}",
|
||||
"hints": [
|
||||
"A pivot point splits the array into equal prefix and suffix. If no change is made to the array, the goal is to find the number of pivot p such that prefix[p-1] == suffix[p].",
|
||||
"Consider how prefix and suffix will change when we change a number nums[i] to k.",
|
||||
|
Reference in New Issue
Block a user