Paires avec une différence spécifique
function findPairsWithGivenDifference(arr, k):
# since we don't allow duplicates, no pair can satisfy x - 0 = y
if k == 0:
return []
map = {}
answer = []
for (x in arr):
map[x - k] = x
for (y in arr):
if y in map:
answer.push([map[y], y])
return answer
Aggressive Ant