@@ -0,0 +1,676 @@
+package advanced.scan.cumulative.lc560_subarraysumequalsk;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0A/**%0A * Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.%0A */%0Apublic class Solution %7B%0A%0A    public int subarraySum(int%5B%5D nums, int k) %7B%0A        Map%3CInteger,Integer%3E presum = new HashMap%3C%3E();%0A        presum.put(0, 1); // Don't forget!%0A        int cnt = 0;%0A        for (int i = 0, sum = 0; i %3C nums.length; i++) %7B%0A            sum += nums%5Bi%5D;%0A            cnt += presum.getOrDefault(sum - k, 0);%0A            presum.put(sum, presum.getOrDefault(sum, 0) + 1);%0A        %7D%0A        return cnt;%0A    %7D%0A%0A%7D%0A

subarray sum equals k