null
Wrapper class // Note: The class name 'Wrapper' is being used only to avoid compilation errors. // You will need to refactor the name of the class as well as the names of the methods // when creating your own classes and package structures. class Solution{ public int subarraySum(int[] nums, int k) { Map<Integer, Integer> map = new HashMap<>(); map.put(0, 1); int count = 0, sum = 0; for (int i = 0; i < nums.length; i++) { sum += nums[i]; if (map.containsKey(sum - k)) { count += map.get(sum - k); } map.put(sum, map.getOrDefault(sum, 0) + 1); } return count; } } public static void main(String[] args) { System.out.println("Hello, World!"); } }
[Source](https://leetcode.com/problems/subarray-sum-equals-k/)