Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution(object):
- def kClosest(self, points, K):
- """
- :type points: List[List[int]]
- :type K: int
- :rtype: List[List[int]]
- """
- result = []
- for point in points:
- heapq.heappush(result, (point[0] * point[0] + point[1] * point[1], point))
- return [r[1] for r in heapq.nsmallest(K, result)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement