update 1
This commit is contained in:
parent
2747422c40
commit
370535504e
@ -6,9 +6,15 @@ class Solution:
|
||||
def twoSum(self, nums: list[int], target: int) -> list[int]:
|
||||
answer = []
|
||||
for i in range(len(nums) // 2 + 1):
|
||||
if target - nums[i] == nums[i]:
|
||||
continue
|
||||
if target - nums[i] in nums:
|
||||
another = target - nums[i]
|
||||
|
||||
# both number in the list
|
||||
if another in nums:
|
||||
if nums[i] == another:
|
||||
temp_list = nums
|
||||
temp_list.pop(i)
|
||||
if another not in temp_list:
|
||||
continue
|
||||
answer.append(i)
|
||||
answer.append(nums.index(target - nums[i]))
|
||||
return answer
|
||||
|
Loading…
x
Reference in New Issue
Block a user