daily log 10.03.20
class Solution(object):
def findPairs(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: int
"""
my_dict = {}
for num in nums:
if num not in my_dict:
my_dict[num] = 1
else:
my_dict[num] = my_dict[num] + 1
if k == 0:
dupes = [k for k,v in my_dict.items() if v>1]
return len(dupes)
results = []
for num in nums:
if num + k in my_dict:
results.append((num, num+k))
return len(set(results))