Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def kClosest(self, points: List[List[int]], k: int) -> List[List[int]]:
- dist = [[math.sqrt(x**2 + y**2), x, y] for (x, y) in points]
- heapq.heapify(dist)
- res = []
- for i in range(k):
- d, x, y = heapq.heappop(dist)
- res.append([x, y])
- return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement