All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : June 29, 2024
Last updated : September 26, 2024
Related Topics : Array, Math, Divide and Conquer, Geometry, Sorting, Heap (Priority Queue), Quickselect
Acceptance Rate : 67.02 %
class Solution:
def kClosest(self, points: List[List[int]], k: int) -> List[List[int]]:
return sorted(points, key=lambda x: x[0]**2 + x[1]**2)[:k]
class Solution:
def kClosest(self, points: List[List[int]], k: int) -> List[List[int]]:
return sorted(points, key=lambda x: sqrt(x[0]**2 + x[1]**2))[:k]