We have a list of
points
on the plane. Find theK
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.)
Note:
1 <= K <= points.length <= 10000
-10000 < points[i][0] < 10000
-10000 < points[i][1] < 10000
在平面上我們擁有一個列表的點。找到前
K
個最靠近原點(0, 0)
的點。
(在這裡,兩點的距離定義為歐氏距離。)
你用任何順序可以回傳答案。答案保證是唯一的(除了不同排序)。
提示:
1 <= K <= points.length <= 10000
-10000 < points[i][0] < 10000
-10000 < points[i][1] < 10000
resize()
拿出前K
項。LeetCode
C++