Python-Algos: Array Pair Sum

def pair_sum(arr, C):
if len(arr)<2:
return
seen = set()
output = set()
for num in arr:
target = C - num
if target not in seen:
seen.add(num)
else:
output.add((min(num,target), max(num,target)))
print ('\n'.join(map(str,list(output))))

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Avitosh Totaram

Avitosh Totaram

Problem solver with experience in Software, and Mechanical engineering. Interested in web-dev, machine learning, artificial intelligence, and new technologies.