Coding Challenge

K Closest Points to Origin

Medium
heapgeometry

Return the k points closest to the origin.

Given points in 2D space, return the k points with the smallest Euclidean distance from the origin.

Examples

Input: points = [[1,3],[-2,2]], k = 1

Output: [[-2,2]]

Constraints

  • Order of returned points does not matter

Preparing your coding workspace...