class Solution(object):
def findPairs(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: int
"""
d = collections.Counter(nums)
ans = 0
for key, value in d.items():
if k == 0:
ans += (d.get(key + k, 0) > 1)
else:
ans += (d.get(key + k, 0) > 0)
return ans