class Solution(object):
def countKDifference(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: int
暴力?dict吧
"""
ans=0
dict_temp={}
for i in nums:
if dict_temp.has_key(i):
dict_temp[i]+=1
else:
dict_temp[i]=1
for i in dict_temp:
if dict_temp.has_key(i+k):
ans+=dict_temp[i]*dict_temp[i+k]
return ans