1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-02 14:12:17 +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>0</strong>&nbsp;开始的整数数组&nbsp;<code>nums</code>&nbsp;,请你找到 <strong>最左边</strong>&nbsp;的中间位置&nbsp;<code>middleIndex</code>&nbsp;(也就是所有可能中间位置下标最小的一个)。</p>\n\n<p>中间位置&nbsp;<code>middleIndex</code>&nbsp;是满足&nbsp;<code>nums[0] + nums[1] + ... + nums[middleIndex-1] == nums[middleIndex+1] + nums[middleIndex+2] + ... + nums[nums.length-1]</code>&nbsp;的数组下标。</p>\n\n<p>如果&nbsp;<code>middleIndex == 0</code>&nbsp;,左边部分的和定义为 <code>0</code>&nbsp;。类似的,如果&nbsp;<code>middleIndex == nums.length - 1</code>&nbsp;,右边部分的和定义为&nbsp;<code>0</code>&nbsp;。</p>\n\n<p>请你返回满足上述条件 <strong>最左边</strong>&nbsp;的<em>&nbsp;</em><code>middleIndex</code>&nbsp;,如果不存在这样的中间位置,请你返回&nbsp;<code>-1</code>&nbsp;。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<b>输入:</b>nums = [2,3,-1,<em><strong>8</strong></em>,4]\n<b>输出:</b>3\n<strong>解释:</strong>\n下标 3 之前的数字和为2 + 3 + -1 = 4\n下标 3 之后的数字和为4 = 4\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<b>输入:</b>nums = [1,-1,<em><strong>4</strong></em>]\n<b>输出:</b>2\n<strong>解释:</strong>\n下标 2 之前的数字和为1 + -1 = 0\n下标 2 之后的数字和为0\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre>\n<b>输入:</b>nums = [2,5]\n<b>输出:</b>-1\n<b>解释:</b>\n不存在符合要求的 middleIndex 。\n</pre>\n\n<p><strong>示例 4</strong></p>\n\n<pre>\n<b>输入:</b>nums = [<em><strong>1</strong></em>]\n<b>输出:</b>0\n<strong>解释:</strong>\n下标 0 之前的数字和为0\n下标 0 之后的数字和为0\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= nums.length &lt;= 100</code></li>\n\t<li><code>-1000 &lt;= nums[i] &lt;= 1000</code></li>\n</ul>\n\n<p>&nbsp;</p>\n\n<p><strong>注意:</strong>本题与主站 724 题相同:<a href=\"https://leetcode-cn.com/problems/find-pivot-index/\" target=\"_blank\">https://leetcode-cn.com/problems/find-pivot-index/</a></p>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 17,
"likes": 18,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -143,7 +143,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"9.2K\", \"totalSubmission\": \"14K\", \"totalAcceptedRaw\": 9180, \"totalSubmissionRaw\": 13995, \"acRate\": \"65.6%\"}",
"stats": "{\"totalAccepted\": \"10.1K\", \"totalSubmission\": \"15.5K\", \"totalAcceptedRaw\": 10137, \"totalSubmissionRaw\": 15534, \"acRate\": \"65.3%\"}",
"hints": [
"Could we go from left to right and check to see if an index is a middle index?",
"Do we need to sum every number to the left and right of an index each time?",