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
Open every published interview problem, solution, scene, and memory room free, with no account.