package leetcode;

/**
 * https://leetcode.com/problems/gas-station/
 */
public class Problem134 {
    public int canCompleteCircuit(int[] gas, int[] cost) {
        // TODO: to be implemented
        return 0;
    }
}

@@ -163,51 +163,1384 @@
     
-// TODO: to be implemented%0A        return 0
+int totalGas = 0;%0A        int totalCost = 0;%0A        for (int g : gas) %7B%0A            totalGas += g;%0A        %7D%0A        for (int c : cost) %7B%0A            totalCost += c;%0A        %7D%0A        if (totalCost %3E totalGas) %7B%0A            return -1;%0A        %7D%0A        int%5B%5D diff = new int%5Bgas.length%5D;%0A        for (int i = 0; i %3C gas.length; i++) %7B%0A            int g = gas%5Bi%5D;%0A            int c = cost%5Bi%5D;%0A            int x = g - c;%0A            diff%5Bi%5D = x;%0A        %7D%0A        int max = Integer.MIN_VALUE;%0A        int maxIdx = 0;%0A        for (int i = 0; i %3C diff.length; i++) %7B%0A            int sum = 0;%0A            for (int j = i; j %3C diff.length + i; j++) %7B%0A                int k = j;%0A                if (k %3E= diff.length) %7B%0A                    k = j - diff.length;%0A                %7D%0A                sum += diff%5Bk%5D;%0A                if (sum %3C 0) %7B%0A                    break;%0A                %7D%0A            %7D%0A            if (sum %3E max) %7B%0A                max = sum;%0A                maxIdx = i;%0A            %7D%0A        %7D%0A        return maxIdx;%0A    %7D%0A    %0A    public static void main(String%5B%5D args) %7B%0A        Problem134 prob = new Problem134();%0A        System.out.println(prob.canCompleteCircuit(%0A            new int%5B%5D%7B1, 2, 3, 3%7D,%0A            new int%5B%5D%7B2, 1, 5, 1%7D));%0A        System.out.println(prob.canCompleteCircuit(%0A            new int%5B%5D %7B6, 1, 4, 3, 5%7D,%0A            new int%5B%5D %7B3, 8, 2, 4,2%7D))
 ;%0A  

Write something for problem 134 (it's still TLE)