File tree Expand file tree Collapse file tree 1 file changed +4
-13
lines changed Expand file tree Collapse file tree 1 file changed +4
-13
lines changed Original file line number Diff line number Diff line change @@ -8,30 +8,21 @@ class Solution:
88 공간 복잡도는 둘다 O(1)
99 """
1010 def threeSum (self , nums : List [int ]) -> List [List [int ]]:
11- result = []
11+ result = set ()
1212 nums .sort ()
1313
14- for i in range (len (nums )):
15- if i > 0 and nums [i ] == nums [i - 1 ]:
16- continue
17-
14+ for i in range (len (nums )):
1815 left , right = i + 1 , len (nums ) - 1
1916 while left < right :
2017 total = nums [i ] + nums [left ] + nums [right ]
2118
2219 if total == 0 :
23- result .append ([ nums [i ], nums [left ], nums [right ]] )
20+ result .add (( nums [i ], nums [left ], nums [right ]) )
2421 left += 1
2522 right -= 1
26-
27- while left < right and nums [left ] == nums [left - 1 ]:
28- left += 1
29- while left < right and nums [right ] == nums [right + 1 ]:
30- right -= 1
31-
3223 elif total < 0 :
3324 left += 1
3425 else :
3526 right -= 1
3627
37- return result
28+ return list ( result )
You can’t perform that action at this time.
0 commit comments