Skip to content

Commit 4eb7761

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent b8cb2fa commit 4eb7761

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

data_structures/arrays/gas_station.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import List
22

3+
34
class Solution:
45
def canCompleteCircuit(self, gas: List[int], cost: List[int]) -> int:
56
# Step 1: Initialize variables
@@ -9,13 +10,13 @@ def canCompleteCircuit(self, gas: List[int], cost: List[int]) -> int:
910
total_gas = 0
1011
current_gas = 0
1112
start_station = 0
12-
13+
1314
# Step 2: Loop through each gas station
1415
for i in range(len(gas)):
1516
# Calculate the net gas gain/loss at the current station
1617
total_gas += gas[i] - cost[i]
1718
current_gas += gas[i] - cost[i]
18-
19+
1920
# Step 3: If current_gas becomes negative, it means we cannot continue
2021
# the journey from the current start_station, so we update the start_station
2122
# to the next one and reset the current_gas to 0.

0 commit comments

Comments
 (0)