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):
seen = set()
output = set() for num in arr:
target = C - num
if target not in seen:
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!