Coding

Find the K closest points to the origin.

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).

Input: points = [[3,3],[5,-1],[-2,4]], k = 2

Output: [[3,3], [-2,4]]

Explanation: The squared distances are 18, 26, and 20 respectively. The two smallest distances belong to [3,3] and [-2,4].

Was asked at

Practice this question with AI

First session is free - no credit card required.

Go Premium

More interviews, more skills, more success.

Community Answers

1 answer from the community

Unlock Full Access

Answer any un-answered question from our database to unlock all community answers for 30 days.

Give & Take

Practice More Questions

1 answer published. Last candidate submission on Sep 20 2026, 6:19pm PDT. Interview question asked to Software Engineers interviewing at Blind, SoFi, Rivigo and other companies. Original question asked: Find the K closest points to the origin.. Question last reported by a candidate interviewing at Dropbox for a Software Engineer interview on Sep 29 2026, 5:08am PDT.