O58
Gas Station Circular Tour
Problem Statement & Objective
There are n gas stations along a circular route. Return the starting gas station's index if you can travel around the circuit once, otherwise return -1.
Function Signature (Python)
gas_station_circular_tour(gas: list[int], cost: list[int]) -> intInput & Output Contract
Output Rule:Başlangıç istasyonu indeksi (0-tabanlı) veya -1.
System Constraints
n == benzin.length == maliyet.length
1 <= n <= 10^5
0 <= benzin[i], maliyet[i] <= 10^4Example Execution Walkthrough
benzin = [1, 2, 3, 4, 5], maliyet = [3, 4, 5, 1, 2]
3. istasyondan başlanırsa tur tamamlanabilir -> cevap: 3Example Test Scenarios (3)
Example 1
Input:
[[1,2,3,4,5],[3,4,5,1,2]]Expected Output:
3Example 2: Yetersiz Toplam
Input:
[[2,3,4],[3,4,3]]Expected Output:
-1Example 3: Tek İstasyon
Input:
[[5],[4]]Expected Output:
0