You are viewing a single comment's thread. Return to all comments →
def pairs(k, arr): m = {} pairs = 0 for num in arr: complement = num + k if complement in m: pairs += m[complement] else: m[complement] = m.get(complement, 0) + 1 for num in arr: if num in m: pairs += m[num] return pairs
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 →