# Python-Algos: Array Pair Sum

They’re many ways to approach this problem, but you have to consider the time it takes to run the code once the data becomes much bigger than your sample test data.

The Array Pair Sum problem: Given an integer array, output all the unique pairs that sum up to a specific value C.

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))))

This code has a big O notation of n which is exponential due to having to do two loops. Remember that spaces matter when coding with python!