Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.

For example: Given an array
[1,1,1] and k =2
answer is 2	
public class Solution { 
	 public int subarraySum(int[] nums, int k) {
		int count = 0;
		int end = 0;
		int sum = 0;
		Map map = new HashMap<>();
        map.put(0,1);
		while (end < nums.length) {
			sum +=nums[end++];
			if (map.containsKey(sum -k)) {
				count += map.get(sum-k);
			}
			map.put(sum, map.getOrDefault(sum, 0) + 1);
		}
		return count;
	}
}