Sharing my concise python solution


  • 0
    Z
    class Solution(object):
        def twoSum(self, nums, target):
            """
            :type nums: List[int]
            :type target: int
            :rtype: List[int]
            """
            for num in nums:
                [cut, num2] = [nums.index(num) + 1, target - num]
                if num2 in nums[cut:]:
                    return [nums.index(num), nums.index(num2, cut, )]
    
    

Log in to reply
 

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