← All problemsSign in

Thomas and gas stations

Thomas is a 19-year-old boy who always travels around the world. One day his uncle Jack plans a trip via the road. Given two integer arrays, A and B of size N. There are N gas stations along a circular route, where the amount of gas at station i is A[i]. They have a car with an unlimited gas tank and it costs B[i] of gas to travel from station i to its next station (i+1). They begin the journey wi

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start