leetcode 15
-
15. 3SumProgramming/leetcode 2021. 2. 1. 13:08
예전에 풀었던 2Sum에 이은 3Sum문제.. a + b + c = 0이 되는 조합을 출력하는 것이고, 중복 조합은 허락하지 않는다. 중복을 허락하지 않으므로, set으로 결과 관리를 하면 될것 같음 n^3으로 풀릴것도 같다. 1) 첫번째 도전 (for문 3번) def threeSum(self, nums: List[int]) -> List[List[int]]: ans = [] nums.sort() check = set() for i in range(len(nums)): for j in range(i+1, len(nums)): for k in range(j+1, len(nums)): a, b, c, = nums[i], nums[j], nums[k] if a+b+c == 0 and (a,b,c) not in..