Python O(n) solution using hashmap
```\nclass Solution:\n    def findPairs(self, nums: List[int], k: int) -> int:\n        \n        hashNums={}\n        pairs=set()\n        \n        for n in n
```\nclass Solution:\n    def findPairs(self, nums: List[int], k: int) -> int:\n        \n        hashNums={}\n        pairs=set()\n        \n        for n in nums: # O(n)\n            hashNums[n]=hashNums.get(n,0)+1\n            \n            if n-k in hashNums:\n                pairs.add(tuple(set([n,n-k])))\n            \n            if n+k in hashNums:\n                pairs.add(tuple(set([n,n+k])))\n        \n        if k==0: # O(n)\n            ct=0\n            for n,f in hashNums.items():\n                ct+=(f>=2)\n            return ct\n        \n        return len(pairs)
[]