Subarray Sum Equals K




@FF_TI No need of put(0,1):
public int subarraySum(int[] nums, int k) { int count=0,sum=0; Map<Integer,Integer> hm = new HashMap<>(); for(int i=0;i<nums.length;i++){ hm.put(sum, hm.getOrDefault(sum,0)+1); sum+=nums[i]; count+=hm.getOrDefault((sumk),0); } return count; }