Two Sum II - Python, 49ms


  • 0
    Y
    class Solution(object):
        def twoSum(self, numbers, target):
            num1 = list(set(numbers))
            for f in num1:
                if((target-f) in num1):
                    if f!=(target-f):
                        li = [numbers.index(f)+1,numbers.index(target-f)+1]
                        li.sort()
                        return(li[0],li[1])
                    elif f==(target-f):
                        return(numbers.index(f)+1, numbers.index(f)+2)

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.