Time Limit exceeded

  • 0

    class Solution(object):
    def twoSum(self, nums, target):
    :type nums: List[int]
    :type target: int
    :rtype: List[int]
    lis =[]
    for i in range(len(nums)-1):
    sec_elem = target - nums[i]
    if sec_elem in nums[i+1:]:
    sec_index = nums.index(sec_elem,i)
    if sec_index == i:
    sec_index = nums.index(sec_elem,i+1)
    return lis

        return []

Log in to reply

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