Loading...
Loading...
Cookie choices
WoHoTech uses essential cookies for login and site features. Non-essential analytics and advertising scripts load only after you accept them.
Read privacy policyGiven 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** (√(x1² + x2²)). You may return the answer in **any order**.
Example 1
Input: points = [[1,3],[-2,2]], k = 1 Output: [[-2,2]] Explanation: Distance of [1,3] is sqrt(10); distance of [-2,2] is sqrt(8). Closer.
Example 2
Input: points = [[3,3],[5,-1],[-2,4]], k = 2 Output: [[3,3],[-2,4]]