From d257ab3564426f98feaecc3ff3ece3a4845a5543 Mon Sep 17 00:00:00 2001 From: ImAlpha Date: Mon, 4 Sep 2023 21:36:51 -0700 Subject: [PATCH] first attempt, solves 12/78 --- NeetCodeRoadmap/Arrays_and_Hashing/15_3Sum.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/NeetCodeRoadmap/Arrays_and_Hashing/15_3Sum.py b/NeetCodeRoadmap/Arrays_and_Hashing/15_3Sum.py index e69de29..641b851 100644 --- a/NeetCodeRoadmap/Arrays_and_Hashing/15_3Sum.py +++ b/NeetCodeRoadmap/Arrays_and_Hashing/15_3Sum.py @@ -0,0 +1,17 @@ +def threeSum(nums): + """ + :type nums: List[int] + :rtype: List[List[int]] + """ + # Always end at net zero from the sum + first = 0 + second = 1 + solutionSets = [] + + for i in range(len(nums)): + if nums[first] + nums[second] + nums[i] == 0: + solutionSets.append([nums[first], nums[second], nums[i]]) + + + +print(threeSum([-1,0,1,2,-1,-4])) \ No newline at end of file