package leetcode;

/**
 * https://leetcode.com/problems/subarray-sums-divisible-by-k/
 */
public class Problem974 {
    public int subarraysDivByK(int[] A, int K) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem974 prob = new Problem974();
    }
}

@@ -170,129 +170,784 @@
     
-// TODO%0A        return 0;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem974 prob = new Problem974();
+int%5B%5D sums = new int%5BA.length%5D;%0A        int sum = 0;%0A        for (int i = 0; i %3C A.length; i++) %7B%0A            sum += A%5Bi%5D;%0A            sums%5Bi%5D += sum;%0A        %7D%0A        int answer = 0;%0A        for (int i = 0; i %3C sums.length; i++) %7B%0A            if (sums%5Bi%5D %25 K == 0) %7B%0A                answer++;%0A            %7D%0A            for (int j = i - 1; j %3E= 0; j--) %7B%0A                if ((sums%5Bi%5D - sums%5Bj%5D) %25 K == 0) %7B%0A                    answer++;%0A                %7D%0A            %7D%0A        %7D%0A        return answer;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem974 prob = new Problem974();%0A        System.out.println(prob.subarraysDivByK(new int%5B%5D%7B4, 5, 0, -2, -3, 1%7D, 5)); // 7%0A        // %5B4, 5, 0, -2, -3, 1%5D, %5B5%5D, %5B5, 0%5D, %5B5, 0, -2, -3%5D, %5B0%5D, %5B0, -2, -3%5D, %5B-2, -3%5D
 %0A   

Update problem 974