From 43c2705a63c03ee8ccaa5c98fb3376784abfb0c7 Mon Sep 17 00:00:00 2001 From: sangge-rockpi <2251250136@qq.com> Date: Fri, 19 Jan 2024 20:57:18 +0800 Subject: [PATCH] update 1 --- leetcode/1.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/leetcode/1.py b/leetcode/1.py index f8bf37a..b646c56 100644 --- a/leetcode/1.py +++ b/leetcode/1.py @@ -5,7 +5,7 @@ class Solution: def twoSum(self, nums: list[int], target: int) -> list[int]: answer = [] - for i in range(len(nums) // 2 + 1): + for i in range(len(nums)): another = target - nums[i] # both number in the list @@ -22,9 +22,6 @@ class Solution: continue answer.append(i) answer.append(nums.index(another)) - print(nums) - print(another) - print(nums.index(another)) return answer return answer @@ -34,3 +31,8 @@ test = [3, 2, 4] TARGET_NUMBER = 6 a = Solution().twoSum(test, TARGET_NUMBER) print(a) + +test2 = [i for i in range(1, 10001)] +TARGET_NUMBER = 19999 +print(test2[9998], test2[9999]) +print(Solution().twoSum(test2, TARGET_NUMBER))