Easy · Hash Maps
Find K closest to center
Given a list of integer points and an integer k, return the k points closest to the origin (0, 0) by Euclidean distance, in any order.
Examples
Example 1
[(1,3),(-2,2),(5,8),(0,1)] k=2Output: (0,1), (-2,2)
Example 2
[(3,3),(5,-1),(-2,4)] k=2Output: (3,3), (-2,4)
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.