Problem
You get an array points and an integer k. Each item points[i] = [xi, yi] is a point on a plane. Return the k points that are closest to the origin, the point (0, 0).
The distance between two points is the Euclidean distance, sqrt((x1 - x2)^2 + (y1 - y2)^2).
You can return the points in any order. The answer is unique, except for the order of the points.
Example 1
- Input:
- points = [[2,3],[-1,1],[4,-4]], k = 1
- Output:
- [[-1,1]]
- Explanation:
- The squares of the distances are 13, 2 and 32. The point
[-1, 1]is the closest point.
Example 2
- Input:
- points = [[0,5],[3,-3],[-2,-1],[6,0]], k = 2
- Output:
- [[-2,-1],[3,-3]]
- Explanation:
- The squares of the distances are 25, 18, 5 and 36. The two smallest are 5 and 18.
Constraints
- 1 <= k <= points.length <= 10^4
- -10^4 <= xi, yi <= 10^4
- The answer is unique, except for the order of the points.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Kth Largest Element in an Array
Coding · Array · Divide and Conquer · Heap (Priority Queue)
- Top K Frequent Elements
Coding · Array · Bucket Sort · Counting
- Maximum Number of Visible Points
Coding · Array · Geometry · Math
- Sell Diminishing-Valued Colored Balls
Coding · Array · Binary Search · Greedy
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 3 records
Amazon
Leetcode 973. K Closest Points to Origin
Reported Feb 7, 2025 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceAsana
Leetcode 973. K Closest Points to Origin
Reported Aug 12, 2026 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceMeta
Leetcode 973. K Closest Points to Origin
Reported Apr 30, 2026 · 26 source reports
MANAGER, MID_LEVEL, SENIOR, STAFF
Source snapshot: Nov 12, 2026
View source
LeetCode company tags · 1 record
Airbnb
K Closest Points to Origin