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>nums</code> (下标 <strong>从 0 开始</strong> 计数)以及两个整数 <code>target</code> 和 <code>start</code> ,请你找出一个下标 <code>i</code> ,满足 <code>nums[i] == target</code> 且 <code>abs(i - start)</code> <strong>最小化</strong> 。注意:<code>abs(x)</code> 表示 <code>x</code> 的绝对值。</p>\n\n<p>返回 <code>abs(i - start)</code> 。</p>\n\n<p>题目数据保证 <code>target</code> 存在于 <code>nums</code> 中。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>nums = [1,2,3,4,5], target = 5, start = 3\n<strong>输出:</strong>1\n<strong>解释:</strong>nums[4] = 5 是唯一一个等于 target 的值,所以答案是 abs(4 - 3) = 1 。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>nums = [1], target = 1, start = 0\n<strong>输出:</strong>0\n<strong>解释:</strong>nums[0] = 1 是唯一一个等于 target 的值,所以答案是 abs(0 - 0) = 0 。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<strong>输入:</strong>nums = [1,1,1,1,1,1,1,1,1,1], target = 1, start = 0\n<strong>输出:</strong>0\n<strong>解释:</strong>nums 中的每个值都是 1 ,但 nums[0] 使 abs(i - start) 的结果得以最小化,所以答案是 abs(0 - 0) = 0 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= nums.length <= 1000</code></li>\n\t<li><code>1 <= nums[i] <= 10<sup>4</sup></code></li>\n\t<li><code>0 <= start < nums.length</code></li>\n\t<li><code>target</code> 存在于 <code>nums</code> 中</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 6,
|
||||
"likes": 7,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -137,7 +137,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"9.3K\", \"totalSubmission\": \"13.7K\", \"totalAcceptedRaw\": 9278, \"totalSubmissionRaw\": 13697, \"acRate\": \"67.7%\"}",
|
||||
"stats": "{\"totalAccepted\": \"9.3K\", \"totalSubmission\": \"13.7K\", \"totalAcceptedRaw\": 9298, \"totalSubmissionRaw\": 13734, \"acRate\": \"67.7%\"}",
|
||||
"hints": [
|
||||
"Loop in both directions until you find the target element.",
|
||||
"For each index i such that nums[i] == target calculate abs(i - start)."
|
||||
|
Reference in New Issue
Block a user