O(n) super clean 9-line Java solution with HashMap

public int maxSubArrayLen(int[] nums, int k) { int sum = 0, max = 0; HashMap map = new HashMap(); for (int i = 0; i < nums.length; i++) { sum = sum + nums[i]; if (sum == k) max = i + 1; else if (map.containsKey(sum - k)...