LeetCode 973. K Closest Points to Origin
PreviousLeetCode 953. Verifying an Alien DictionaryNextLeetCode 1249. Minimum Remove to Make Valid Parentheses
Last updated
Was this helpful?
Last updated
Was this helpful?
Given an array of points
where points[i] = [xi, yi]
represents a point on the X-Y plane and an integer k
, return the k
closest points to the origin (0, 0)
.
The distance between two points on the X-Y plane is the Euclidean distance (i.e, √(x1 - x2)2 + (y1 - y2)2
).
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:
Example 2:
Constraints:
1 <= k <= points.length <= 104
-104 < xi, yi < 104