> For the complete documentation index, see [llms.txt](https://chiragjain.gitbook.io/neetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chiragjain.gitbook.io/neetcode/973-k-closest-points-to-origin/code.md).

# CODE

```python
class Solution:
    def kClosest(self, points: List[List[int]], k: int) -> List[List[int]]:
        dists = [(x**2 + y**2, (x, y)) for x, y in points]
        heapq.heapify(dists)
        results = [heapq.heappop(dists)[1] for _ in range(k)]
        return results
        
```
