← 返回 meta 的题目列表K Closest Points to Origin
类型:online_judge
meta
Given an array of points on the plane represented as integers points where points[i] = [xi, yi], and an integer k, return the k closest points to the origin (0, 0). Implement and test your solution.
Input: An array of integer points and an integer k.
Output: An array representing the k closest points.
Example:
Input: points = [[1, 3], [-2, 2]], k = 1
Output: [[-2, 2]]
Input: points = [[3, 3], [5, -1], [-2, 4]], k = 2
Output: [[3, 3], [-2, 4]]
Example
Input
[[1,3],[-2,2]], 1