K Closest Points to Origin
We have a list of points on the plane. Find the K closest points to the origin (0, 0).
(Here, the distance between two points on a plane is the Euclidean distance.)
You may return the answer in any order. The answer is guaranteed to be unique (except for the order that it is in.)
在二维坐标列表中,寻找出 K 个离原点最近的坐标值
Solution1
List && Map
1 | private int multi(int[] point) { |
1 | class Solution { |
Solution2
min heap
O (n * logn)
1 | // mock min heap -> poll -> get min element |
1 | private int[][] kClosest2(int[][] points, int K) { |
Solution3
max heap
O (n * logK)
1 | // mock max heap -> poll -> get max element |
1 | private int[][] kClosest3(int[][] points, int K) { |
Solution4
Quick Select
待补充