7 Lines O(n) Python3 (fast and clear and easy understand)
make a dictory,and then when k>0 and k==0, we add res :\npython\n  def findPairs(self, nums, k):\n\t\tnums.sort()\n        res , dic= 0 , {}\n        for i in n
make a dictory,and then when k>0 and k==0, we add res :\n```python\n  def findPairs(self, nums, k):\n\t\tnums.sort()\n        res , dic= 0 , {}\n        for i in nums:\n            dic[i] = dic[i]+1 if i in dic else 1\n        for i in dic.keys():\n            if (i+k in dic and k>0) or (k==0 and dic[i]>1):\n                res += 1\n        return res \n```\n\nIf this code is not bad , welcome give me a star ,Thanks
['Python3']