Easy to Understand Python Solution using hashmap
\n    def findPairs(self, nums, k):\n        """\n        :type nums: List[int]\n        :type k: int\n        :rtype: int\n        """\n        if k < 0:\n    
```\n    def findPairs(self, nums, k):\n        """\n        :type nums: List[int]\n        :type k: int\n        :rtype: int\n        """\n        if k < 0:\n            return 0\n        hashmap = {}\n        count = 0\n        for num in nums:\n            # check num + k and num - k present in hashmap\n            if num not in hashmap:  \n                if num + k in hashmap:\n                    count += 1\n                if num - k in hashmap:\n                    count += 1\n                hashmap[num] = 1\n            else:\n                # handling k == 0 condition with by restricting occurances to 1\n                if k == 0 and hashmap[num] == 1:\n                    count += 1\n                hashmap[num] += 1\n                \n        return count\n```
[]