Search
⌘K

Leetcode 134. Gas Station

Given two arrays gas and cost around a circular route, find the unique starting station index from which you can travel clockwise once without your running fuel (gas[i] - cost[i] cumulative) ever dropping below zero, or return -1 if impossible. The key is that a solution exists iff total gas >= total cost, and you must pick the start where the running sum never becomes negative.

Asked at:

Bloomberg

Bloomberg


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Late January, 2025

Bloomberg

Bloomberg

Junior

Comments

Your account is free and you can post anonymously if you choose.