class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
half = target // 2
if target % 2 == 0 and nums.count(half) >= 2:
result = []
for index, num in enumerate(nums):
if num == half:
result.append(index)
return result
num_index_book = {}
for index, num in enumerate(nums):
num_index_book[num] = index
for num in num_index_book.keys():
num_index = num_index_book[num]
left_over = target - num
left_over_index = num_index_book.get(left_over)
if left_over_index != None and left_over_index != num_index:
return [num_index_book[num], num_index_book[left_over]]