2
public int minSumOfLengths(3
int[] arr, int target) { // this fits the case when there's negative number, kind like 5604
if (arr == null || arr.length == 0) return 0;5
Map<Integer, Integer> map = new HashMap<>(); // sum - index8
for (int i = 0; i < arr.length; i++) { // record preSum and index13
int size = arr.length + 1,14
res = arr.length + 1; // note if we set size as MAX_VALUE the line 16 may overflow15
for (int i = 0; i < arr.length; i++) {17
if (map.containsKey(sum - target))23
sum - target)); // find the subarray from the previous index to current one24
if (map.containsKey(sum + target))29
+ map.get(sum + target)30
- i); // from the current index to next one, this avoid overlap32
return res == arr.length + 1 ? -1 : res;