双指针
有油时候前指针可以前进(烧油),没油时候后指针必须后退(取油),直到两指针碰上。
如果最终油量大于0,可以跑足一圈,否则不能。
class Solution:
    def gasStation(self , gas: List[int], cost: List[int]) -> int:
        # write code here
        sta,end=0,len(gas)-1
        theg=0
        while sta<=end:
            if theg<0:
                theg+=gas[end]-cost[end]
                end+=-1
            else:
                theg+=gas[sta]-cost[sta]
                sta+=1
        if theg>=0:
            return sta
        else:
            return -1