update 1
This commit is contained in:
parent
baab69d5a6
commit
43c2705a63
@ -5,7 +5,7 @@
|
|||||||
class Solution:
|
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)):
|
||||||
another = target - nums[i]
|
another = target - nums[i]
|
||||||
|
|
||||||
# both number in the list
|
# both number in the list
|
||||||
@ -22,9 +22,6 @@ class Solution:
|
|||||||
continue
|
continue
|
||||||
answer.append(i)
|
answer.append(i)
|
||||||
answer.append(nums.index(another))
|
answer.append(nums.index(another))
|
||||||
print(nums)
|
|
||||||
print(another)
|
|
||||||
print(nums.index(another))
|
|
||||||
return answer
|
return answer
|
||||||
|
|
||||||
return answer
|
return answer
|
||||||
@ -34,3 +31,8 @@ test = [3, 2, 4]
|
|||||||
TARGET_NUMBER = 6
|
TARGET_NUMBER = 6
|
||||||
a = Solution().twoSum(test, TARGET_NUMBER)
|
a = Solution().twoSum(test, TARGET_NUMBER)
|
||||||
print(a)
|
print(a)
|
||||||
|
|
||||||
|
test2 = [i for i in range(1, 10001)]
|
||||||
|
TARGET_NUMBER = 19999
|
||||||
|
print(test2[9998], test2[9999])
|
||||||
|
print(Solution().twoSum(test2, TARGET_NUMBER))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user