Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- leetcode풀이
- python Leetcode
- python priority queue
- python sorted
- python xor
- 파이썬릿코드
- 파이썬알고리즘
- 상가수익률계산기
- 잇츠디모
- 릿코드 파이썬
- 파이썬릿코드풀기
- 코틀린기초
- LeetCode
- python zip_longest
- 릿코드 풀기
- binary search
- 릿코드풀기
- 파이썬 알고리즘 풀기
- leetcode 풀기
- 릿코드풀이
- python 릿코드
- leetcode풀기
- 파이썬 릿코드
- 파이썬 알고리즘
- 알고리즘풀이
- 알고리즘풀기
- 릿코드
- python 알고리즘
- 파이썬알고리즘풀기
- 파이썬 프로그래머스
Archives
- Today
- Total
소프트웨어에 대한 모든 것
LeetCode 풀기 - 1200. Minimum Absolute Difference 본문
반응형
1200. Minimum Absolute Difference
https://leetcode.com/problems/minimum-absolute-difference/
Minimum Absolute Difference - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
문제)

솔루션1) Easy one path
class Solution(object):
def minimumAbsDifference(self, arr):
"""
:type arr: List[int]
:rtype: List[List[int]]
"""
arr.sort()
d = {}
for i in range(len(arr)-1):
diff = abs(arr[i+1]-arr[i])
if diff in d:
d[diff].append([arr[i],arr[i+1]])
else:
d[diff] = [[arr[i],arr[i+1]]]
return d[min(d.keys())]
반응형
'알고리즘 > LeetCode' 카테고리의 다른 글
| LeetCode 풀기 - 56. Merge Intervals (0) | 2021.12.24 |
|---|---|
| LeetCode 풀기 - 143. Reorder List (0) | 2021.12.23 |
| LeetCode 풀기 - 1325. Delete Leaves With a Given Value (0) | 2021.12.20 |
| LeetCode 풀기 - 1829. Maximum XOR for Each Query (0) | 2021.12.18 |
| LeetCode 풀기 - 2032. Two Out of Three (0) | 2021.12.18 |
Comments