We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 90bea1d commit 5901324Copy full SHA for 5901324
3sum/yyyyyyyyyKim.py
@@ -0,0 +1,36 @@
1
+class Solution:
2
+ def threeSum(self, nums: List[int]) -> List[List[int]]:
3
+
4
+ answer = []
5
6
+ # 정렬
7
+ nums.sort()
8
9
+ for i in range(len(nums)-2):
10
+ # i 중복제거
11
+ if i > 0 and nums[i] == nums[i - 1]:
12
+ continue
13
14
+ left = i+1
15
+ right = len(nums)-1
16
17
+ while left < right:
18
+ if nums[i] + nums[left] + nums[right] == 0:
19
+ answer.append([nums[i],nums[left],nums[right]])
20
21
+ # left 중복제거
22
+ while left < right and nums[left] == nums[left+1]:
23
+ left += 1
24
+ # right 중복제거
25
+ while left < right and nums[right] == nums[right-1]:
26
+ right -= 1
27
28
29
30
31
+ elif nums[i] + nums[left] + nums[right] < 0:
32
33
+ else:
34
35
36
+ return answer
0 commit comments