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]:
|
def twoSum(self, nums: list[int], target: int) -> list[int]:
|
||||||
answer = []
|
answer = []
|
||||||
for i in range(len(nums) // 2 + 1):
|
for i in range(len(nums) // 2 + 1):
|
||||||
if target - nums[i] == nums[i]:
|
another = target - nums[i]
|
||||||
continue
|
|
||||||
if target - nums[i] in nums:
|
# 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(i)
|
||||||
answer.append(nums.index(target - nums[i]))
|
answer.append(nums.index(target - nums[i]))
|
||||||
return answer
|
return answer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user