Skip to content

Commit be79e48

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

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

data_structures/arrays/gas_station.py

+4-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 can_complete_circuit(self, gas: list[int], cost: list[int]) -> int:
56
# Step 1: Initialize variables
@@ -9,13 +10,13 @@ def can_complete_circuit(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.
@@ -31,6 +32,7 @@ def can_complete_circuit(self, gas: list[int], cost: list[int]) -> int:
3132
# If total_gas is non-negative, return the start_station as the answer
3233
return start_station
3334

35+
3436
# Example usage with hints:
3537

3638
# Example 1:

0 commit comments

Comments
 (0)