You are viewing a single comment's thread. Return to all comments →
Python 3 solution
def pairs(k, arr): arr.sort() d = dict() res = 0 for i in range(len(arr)): if arr[i] - k in d: res += 1 d[arr[i]] = i return res
Seems like cookies are disabled on this browser, please enable them to open this website
Pairs
You are viewing a single comment's thread. Return to all comments →
Python 3 solution