My python solution


  • 1

    class Solution(object):
    def twoSum(self, nums, target):
    """
    :type nums: List[int]
    :type target: int
    :rtype: List[int]
    """
    l=len(nums)
    r=range(l)
    t=[x for x in r if (target-nums[x]) in (nums[:x]+nums[x+1:])]
    return t


  • 0
    S

    This solution will return [1, 2, 3] for the list [12, 2, 2, 7, 13, 11] and target 9.


Log in to reply
 

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