Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 1.2 KB

_973. K Closest Points to Origin.md

File metadata and controls

40 lines (28 loc) · 1.2 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


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 %


Solutions

Python

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]