jeudi 27 mai 2010

Given a list of integers, some of which may be negative, extract the pair that sums to the largest number.


a = t[0]
b = t[1]
max = a + b
for i in range(1,len(t))
ta = t[i]
for j in range(i+1,len(t))
tb = t[j]
if ta + tb > max
a = ta
b = tb

print a,b

Aucun commentaire:

Enregistrer un commentaire