Readable & Simple Python
O(n) Time.\nO(n) Space.\n\nfrom collections import Counter\nclass Solution:\n    def findPairs(self, nums: List[int], k: int) -> int:\n\t\t#If k is less than 0,
O(n) Time.\nO(n) Space.\n```\nfrom collections import Counter\nclass Solution:\n    def findPairs(self, nums: List[int], k: int) -> int:\n\t\t#If k is less than 0, then the result is 0 since we are looking fpr pairs with an ABSOLUTE difference of k.\n        if k < 0:\n            return 0\n        \n        count = Counter(nums)\n        pairs = set([])\n        \n        for num in count.keys():\n\t\t\t#Special case: If k == 0, then there needs to be at least two occurences of a particular num in nums \n\t\t\t#in order for there to be a pair (num, num).\n            if k == 0:\n                if count[num] > 1:\n                    pairs.add((num, num))\n\t\t\t\t\t\n\t\t\t#Regular case: k != 0. Simply check if num + k is a member of the array nums.\n\t\t\t#Insert the pair into the set of pairs (smallerNum, largerNum) so that there are no duplicate pairs.\n            else:\n                otherNum = num + k\n                if otherNum in count:\n                    pairs.add((num, otherNum) if num <= otherNum else (otherNum, num))\n                    \n        return len(pairs)\n```
['Ordered Set', 'Python']