This commit is contained in:
programmercarl
2023-02-08 17:28:04 +08:00
parent d107b53a4a
commit 1ec9d9bcb4
22 changed files with 146 additions and 148 deletions

View File

@@ -65,7 +65,7 @@ public:
for (int i = 0; i < cost.size(); i++) {
int rest = gas[i] - cost[i]; // 记录剩余油量
int index = (i + 1) % cost.size();
while (rest > 0 && index != i) { // 模拟以i为起点行驶一圈
while (rest > 0 && index != i) { // 模拟以i为起点行驶一圈如果有rest==0那么答案就不唯一了
rest += gas[index] - cost[index];
index = (index + 1) % cost.size();
}