nums
.nums
, populating the hashmap with the count of each number.result
to 0 to count the unique k-diff pairs.k
is greater than 0, check if key + k
exists in the hashmap. If it does, increment result
.
b. If k
is 0, check if the frequency of the key is greater than 1. If it is, increment result
.result
.