As reported: Adobe MTS-2 (C++) interview, one round (August 2025): K Closest Points to Origin, followed by a C++ discussion.
This is LeetCode 973 — K Closest Points to Origin.
Given an array of points where points[i] = [x, y], return the k points closest to the origin (0, 0) by Euclidean distance, in any order. The answer is unique.
Example 1
points = [[1,3],[-2,2]], k = 1
Output: [[-2,2]]
Example 2
points = [[3,3],[5,-1],[-2,4]], k = 2
Output: [[3,3],[-2,4]]
Constraints: 1 ≤ k ≤ points.length ≤ 10^4; -10^4 ≤ x, y ≤ 10^4.
Code runner format: one JSON value per line: points, k. Implement kClosest(points, k); any order is accepted.