There are n gas stations arranged in a circle. You are given two integer arrays gas and cost where:
gas[i] is the amount of gas at station i.cost[i] is the amount of gas it costs to travel from station i to the next station (i + 1) % n.You begin the journey with an empty tank at one of the gas stations. Given that you can travel around the circuit once in the clockwise direction, return the starting station's index if you can complete the circuit, or -1 if it is impossible.
If a solution exists, it is guaranteed to be unique.
Input: gas = [1, 2, 3, 4, 5], cost = [3, 4, 5, 1, 2] Output: 3 Explanation: Start at station 3 (gas = 4). Travel to 4 (4 - 1 + 5 = 8). Travel to 0 (8 - 2 + 1 = 7). Travel to 1 (7 - 3 + 2 = 6). Travel to 2 (6 - 4 + 3 = 5). Travel to 3 (5 - 5 = 0). Circuit complete.
Input: gas = [2, 3, 4], cost = [3, 4, 3] Output: -1 Explanation: Total gas (9) < total cost (10), so completing the circuit is impossible.
gas = [1, 2, 3, 4, 5], cost = [3, 4, 5, 1, 2]