Skip to main content
mediumNeetCode 150

K Closest Points to Origin

Find k closest points to origin (0,0) Return in any order Example: [[1,3],[-2,2]], k=1 => [[-2,2]]

I skip the square root — squared distance orders the same. A size-k heap or one quickselect partition beats sorting everything.

Arrays & HashingHeap / Priority QueueBinary SearchMath & Geometry

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Typing with Coco is free when you sign in, up to a daily limit. Talking with her out loud comes with the $79 pack. Anyone can open the editor and run their code.

1K Closest Points to Originmedium
Based onLeetCode