an alternate soln to the TWO SUMPROBLEM
def twosum(L, target):
for i in range(len(L)):
for j in range(i + 1, len(L)):
if L[i] + L[j] == target:
return i, j
return -1
print(twosum([2, 5, 3, 7, 9], 10))
2 answers ( 0 marked as helpful)
this works, but i think it is a brute force method as explained by Giles in the beginning on paper.
Yes, it's brute force and it's not recommended.