```
int canCompleteCircuit(int* gas, int gasSize, int* cost, int costSize) {
int sum=0,minsum=0,minind=-1,i;
for(i=0;i<gasSize;i++)
{sum=sum+*(gas+i)-*(cost+i);
if(sum<minsum)
{minsum=sum;
minind=i ;
} }
if(sum<0)return -1;
return minind+1;
}
```