Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1c838c7

Browse files
committedOct 6, 2024·
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 044f930 commit 1c838c7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

‎data_structures/arrays/gas_station.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ def can_omplete_circuit(self, gas: list[int], cost: list[int]) -> int:
33
"""
44
Determines the starting gas station index from which you can complete the circuit,
55
or returns -1 if it's not possible.
6-
6+
77
Args:
88
gas (List[int]): List of gas available at each station.
99
cost (List[int]): List of gas costs to travel to the next station.
@@ -23,11 +23,11 @@ def can_omplete_circuit(self, gas: list[int], cost: list[int]) -> int:
2323
total_gas = 0
2424
current_gas = 0
2525
start_station = 0
26-
26+
2727
for i in range(len(gas)):
2828
total_gas += gas[i] - cost[i]
2929
current_gas += gas[i] - cost[i]
30-
30+
3131
if current_gas < 0:
3232
start_station = i + 1
3333
current_gas = 0
@@ -37,7 +37,9 @@ def can_omplete_circuit(self, gas: list[int], cost: list[int]) -> int:
3737
else:
3838
return start_station
3939

40+
4041
# Example usage with doctests
4142
if __name__ == "__main__":
4243
import doctest
44+
4345
doctest.testmod()

0 commit comments

Comments
 (0)
Please sign in to comment.