← Back to all problems
Medium

Gas Station

Updated Feb 24, 2026

Problem

Return starting station index to complete circuit, else -1.

Constraints

1 <= gas.length == cost.length <= 10^5

Examples

Example 1

Input: {"gas": [1, 2, 3, 4, 5], "cost": [3, 4, 5, 1, 2]}
Output: 3

Function Signature

def canCompleteCircuit(self, gas: list[int], cost: list[int]) -> int

How to Submit

Implement a Solution class with a canCompleteCircuit method.

Your method will be called with the input parameters and should return the answer.