Python 3, Faster than 99.77%, Dictionary
\n# Faster than 99.77% of Python3 online submissions\n# Memory Usage: 15.6 MB, less than 34.48% of Python3 online submissions\n\nclass Solution:\n    def findPa
```\n# Faster than 99.77% of Python3 online submissions\n# Memory Usage: 15.6 MB, less than 34.48% of Python3 online submissions\n\nclass Solution:\n    def findPairs(self, nums: List[int], k: int) -> int:\n        # return the number of unique pairs\n        answ=0\n        # create a dictionary: d[x]==nums.count(x)\n        d={}\n        for x in nums:\n            if x in d: d[x]+=1\n            else:      d[x]=1\n        \n        if k: # k>0\n            answ=sum(x+k in d for x in d.keys())\n        else: # k==0\n            answ=sum(k>1 for k in d.values())\n                \n        return answ\n```
['Python', 'Python3']