3 lines python


  • 1
    W
    class Solution(object):
        def twoSum(self, nums, target):
    
            for i in range(len(nums)):
                if (target - nums[i] in nums) and ( not nums.index(target - nums[i]) == i):
                    return [i, nums.index(target - nums[i])]
    '''

Log in to reply
 

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