mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-12-18 02:02:34 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>在一条环路上有 <code>n</code> 个加油站,其中第 <code>i</code> 个加油站有汽油 <code>gas[i]</code><em> </em>升。</p>\n\n<p>你有一辆油箱容量无限的的汽车,从第<em> </em><code>i</code><em> </em>个加油站开往第<em> </em><code>i+1</code><em> </em>个加油站需要消耗汽油 <code>cost[i]</code><em> </em>升。你从其中的一个加油站出发,开始时油箱为空。</p>\n\n<p>给定两个整数数组 <code>gas</code> 和 <code>cost</code> ,如果你可以绕环路行驶一周,则返回出发时加油站的编号,否则返回 <code>-1</code> 。如果存在解,则 <strong>保证</strong> 它是 <strong>唯一</strong> 的。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong> gas = [1,2,3,4,5], cost = [3,4,5,1,2]\n<strong>输出:</strong> 3\n<strong>解释:\n</strong>从 3 号加油站(索引为 3 处)出发,可获得 4 升汽油。此时油箱有 = 0 + 4 = 4 升汽油\n开往 4 号加油站,此时油箱有 4 - 1 + 5 = 8 升汽油\n开往 0 号加油站,此时油箱有 8 - 2 + 1 = 7 升汽油\n开往 1 号加油站,此时油箱有 7 - 3 + 2 = 6 升汽油\n开往 2 号加油站,此时油箱有 6 - 4 + 3 = 5 升汽油\n开往 3 号加油站,你需要消耗 5 升汽油,正好足够你返回到 3 号加油站。\n因此,3 可为起始索引。</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong> gas = [2,3,4], cost = [3,4,3]\n<strong>输出:</strong> -1\n<strong>解释:\n</strong>你不能从 0 号或 1 号加油站出发,因为没有足够的汽油可以让你行驶到下一个加油站。\n我们从 2 号加油站出发,可以获得 4 升汽油。 此时油箱有 = 0 + 4 = 4 升汽油\n开往 0 号加油站,此时油箱有 4 - 3 + 2 = 3 升汽油\n开往 1 号加油站,此时油箱有 3 - 3 + 3 = 3 升汽油\n你无法返回 2 号加油站,因为返程需要消耗 4 升汽油,但是你的油箱只有 3 升汽油。\n因此,无论怎样,你都不可能绕环路行驶一周。</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>gas.length == n</code></li>\n\t<li><code>cost.length == n</code></li>\n\t<li><code>1 <= n <= 10<sup>5</sup></code></li>\n\t<li><code>0 <= gas[i], cost[i] <= 10<sup>4</sup></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 872,
|
||||
"likes": 901,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"160.3K\", \"totalSubmission\": \"291.8K\", \"totalAcceptedRaw\": 160322, \"totalSubmissionRaw\": 291820, \"acRate\": \"54.9%\"}",
|
||||
"stats": "{\"totalAccepted\": \"168.5K\", \"totalSubmission\": \"309.7K\", \"totalAcceptedRaw\": 168510, \"totalSubmissionRaw\": 309724, \"acRate\": \"54.4%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
|
||||
Reference in New Issue
Block a user