Exercises/#138 Gas Station
#138

Gas Station

MediumπŸ“¦ Arrays
85 XP

Problem

Given gas and cost arrays for a circular route, find the starting gas station index to complete the circuit, or -1.

Examples

Input: gas=[1,2,3,4,5], cost=[3,4,5,1,2]
Output: 3

Input: gas=[2,3,4], cost=[3,4,3]
Output: -1
arraygreedy
AI Assistantβ€” powered by AI

Unlock hints progressively β€” start gentle, go deeper only if needed.

πŸ’‘

Level 1: Gentle Nudge

A subtle direction

πŸ—ΊοΈ

Level 2: Approach

The algorithm to use

πŸ”

Level 3: Detailed

Step-by-step guidance

138 / 150

Your Solution

⚑ JavaScript

to save progress and use AI features