Hi guys, my python code is as follows:
import numpy as np class Solution(object): def twoSum(self, numbers, target): """ :type numbers: List[int] :type target: int :rtype: List[int] """ lower = list(filter(lambda x: x < target/2,numbers)) upper = (target - np.array(numbers[len(lower):])).tolist() result = list(set(upper).intersection(lower)) index1 = 1 + numbers.index(result) index2 = 1 + numbers.index(target - result) return [index1, index2]
I submitted that and it shows:
Runtime Error Message: Line 12: IndexError: list index out of range Last executed input: [-1,0], -1
I tested that on my PC, it is fine, can someone tell me where is the problem?