← Questions

K closest points to the origin

0
MetaCodingLast asked Oct 2025

Given points in the plane and k, return the k points nearest to the origin in any order. Start simple (sort by distance), then improve with a size-k max-heap or quickselect and compare the costs.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding