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iPgEAAAQIj4BAACEiE8AAAAh4hMAAECI+AQAABAiPgEAAISITwAAACHiEwAAQMj/B5vGO7DbFVYtAAAAAElFTkSuQmCC" alt="" />

 public int canCompleteCircuit(int[] gas, int[] cost) {
int begin=0;
int sum=0;
int i=0;
int n=0;
int end=0;
int count=gas.length;
while(n<count-1){
sum+=gas[i]-cost[i];
if(sum>=0){
end++;
i=end;
}else{
begin--;
if(begin<0){
begin=count-1;
}
i=begin;
}
n++;
}
sum+=gas[i]-cost[i];
if(sum>=0)
return begin;
else
return -1;
}
上一篇:翻译:在Ubuntu 14.04上安装FTP服务器的方法


下一篇:全局变量和局部变量的理解