brute force method for the two-sum problem doesn’t work

Try this

    nums =[2,5,5,11]
    target = 10
    for i in range(len(nums)-1):
        for j in range(i+1, len(nums)):
            if((nums[i]+nums[j])==target):
                 print(i,j)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top