m
to store the frequency of sums of pairs from nums1
and nums2
.a
in nums1
and b
in nums2
, and add the sum a + b
to the hashmap, incrementing the count if the sum already exists.cnt
to 0 for the number of valid tuples.c
in nums3
and d
in nums4
, and for each pair, check if the negation -(c + d)
exists in the hashmap m
.-(c + d)
from the hashmap to cnt
.cnt
.