3 :
3 :
1st: .
1.
? , .
- . , if (map.containsKey(sum - k)) sum - k. sum - k - , , (sum - k) , k ( k + (sum - k) = sum - ). , count - .
2nd: .
, . , , , count, 0 nums.
count.
. :
subarraySum({0, 0, 0, 7, 0}, 7); 8.
, 0. , , 7, (0: 4). sum = 7 7 - 7 = 0, 3, . - 0. 4. sum - k , count 4.
3rd: Integers .
I think you get the point;) This time, negative numbers can also increase some frequency. If we had a key sum - keyon the map, this means that between the previous sum ( sum - k) and now we had integers that were summed with k(call k + (sum - k) = sum- our current value). If so, let me increase the frequency count.
Rumid source
share