amazon two sum variant
Anonymous User
706

SDE X(might be 1..or 2...or 3....) onsite

standard LP questions then this

input1 => smaller list of nums
input2 => larger list of nums

generate all possible unique sums from two number combos in input1

then iterate over input2 and find the total number of two number combinations that yield each target sum

example:
input1 = [1,2,3,4] yields target sums of [3,4,5,6,7]
input2 = [1..100]

example output(not actually calculated)

{
3: 2, // two combos found that yield value 3 in input2
4: 1,
5: 2,
6: 2,
7: 3
}

Comments (4)