이 글은 "파이썬 알고리즘 인터뷰 (박상길 지음)"을 읽고 주관적으로 요약한 글입니다. 문제 정의 원점(0,0)으로부터 유클리드 거리가 가까운 순서 k개의 좌표 출력 책에서 구현된 코드 class Solution: def kClosest(self, points: List[List[int]], K: int) -> List[List[int]]: heap = [] for (x, y) in points: dist = x ** 2 + y ** 2 heapq.heappush(heap, (dist, x, y)) result = [] for _ in range(K): (dist, x, y) = heapq.heappop(heap) result.append((x, y)) return result 기억해야할 기법 heapq..