my ugly three-line yet working python code


  • 0
            for i in range(len(nums)):
                if target - nums[i] in nums and nums.index(nums[i]) != nums.index(target-nums[i],i) :
                    return [nums.index(nums[i]),nums.index(target-nums[i],i)] 
    

Log in to reply
 

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