nums2.nums2, increment its frequency in the HashMap.add is called, decrement the frequency of the old value and increment the frequency of the new value after addition.count is called, iterate over nums1 and for each element, check if the complement (total - nums1[i]) exists in the HashMap. If it does, add its frequency to the count.