Heap

K Closest Points

Given a list of points on a 2D plane. Find k closest points to the origin (0, 0).

Input: [(1, 1), (2, 2), (3, 3)], 1

Output: [(1, 1)]

Try it yourself

โ†
โ†‘TA ๐Ÿ‘จโ€๐Ÿซ