Leetcode - Heap
973. K Closest Points to Origin[M]
https://leetcode.com/problems/k-closest-points-to-origin/
Description
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.)
Example 1:
1 | Input: points = [[1,3],[-2,2]], K = 1 |
Example 2:
1 | Input: points = [[3,3],[5,-1],[-2,4]], K = 2 |
Note:
1 <= K <= points.length <= 10000-10000 < points[i][0] < 10000-10000 < points[i][1] < 10000
Solution
https://leetcode.com/problems/k-closest-points-to-origin/solution/
1 | class Solution: |
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment





