Skip to content

Instantly share code, notes, and snippets.

View Robogeek95's full-sized avatar
🌍
Somewhere on earth

Azeez Lukman Robogeek95

🌍
Somewhere on earth
View GitHub Profile
class Solution {
public:
int canCompleteCircuit(vector<int> &gas, vector<int> &cost) {
int st=0, left=0, sum=0; // left-gas left in the tank
for (int i=0; i<gas.size(); i++) {
left+=gas[i]-cost[i];
sum+=gas[i]-cost[i];
if (sum<0) {
sum=0;
st=i+1;