Last answered:

12 Oct 2023

Posted on:

27 Jul 2023

2

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

1 answers ( 0 marked as helpful)
Posted on:

12 Oct 2023

2

this works, but i think it is a brute force method as explained by Giles in the beginning on paper.

Submit an answer