From feb856028e88826d77fb64f4b55b6b866be2a2eb Mon Sep 17 00:00:00 2001 From: ImAlpha Date: Wed, 2 Aug 2023 22:33:37 -0700 Subject: [PATCH] answer accepted beats 46% of runtime --- Top150Interview/1_Two_Sum.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Top150Interview/1_Two_Sum.py b/Top150Interview/1_Two_Sum.py index 5962fcd..608d96a 100644 --- a/Top150Interview/1_Two_Sum.py +++ b/Top150Interview/1_Two_Sum.py @@ -4,6 +4,12 @@ def twoSum(nums, target): :type target: int :rtype: List[int] """ + for i in range(len(nums)): + for j in range(i+1, len(nums)): + if nums[i] + nums[j] == target: + #print(f'i is {nums[i]}, j is {nums[j]}') + return [i,j] -twoSum([2,7,11,15], 9) \ No newline at end of file +print(twoSum([2,7,11,15], 9)) +print(twoSum([3,2,4], 6)) \ No newline at end of file