标签:cost for ret int gas div log java can
class Solution { public int canCompleteCircuit(int[] gas, int[] cost) { int total=0,cur=0,start=0; for(int i=0;i<gas.length;i++) { cur+=gas[i]-cost[i]; total+=gas[i]-cost[i]; if(cur<0) { cur=0; start=i+1; } } return total>=0?start:-1; } }
标签:cost for ret int gas div log java can
原文地址:http://www.cnblogs.com/asuran/p/7634045.html