일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Tags
- Python Code
- Substring with Concatenation of All Words
- Protocol
- Python
- iterator
- 109. Convert Sorted List to Binary Search Tree
- data science
- concurrency
- 컴퓨터의 구조
- 밴픽
- attribute
- DWG
- 운영체제
- 43. Multiply Strings
- 30. Substring with Concatenation of All Words
- t1
- 315. Count of Smaller Numbers After Self
- Convert Sorted List to Binary Search Tree
- LeetCode
- 715. Range Module
- Regular Expression
- 프로그래머스
- 시바견
- Decorator
- Class
- shiba
- kaggle
- Generator
- Python Implementation
- 파이썬
Archives
- Today
- Total
목록16. 3Sum Closest (1)
Scribbling
LeetCode: 16. 3Sum Closest
class Solution: def threeSumClosest(self, nums: List[int], target: int) -> int: ret = int(1e9) nums.sort() for i in range(0, len(nums)-2): l = i + 1 r = len(nums) - 1 while l < r: now_sum = nums[i] + nums[l] + nums[r] if now_sum == target: return target elif now_sum < target: if abs(now_sum - target) < abs(ret - target): ret = now_sum l += 1 else: if abs(now_sum - target) < abs(ret - target): re..
Computer Science/Coding Test
2021. 8. 21. 14:35