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

2 answers from the community

Expert Answer

Unlock Full Access

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

Give & Take

Unlock Full Access

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

Give & Take

Practice More Questions

2 answers published. Last candidate submission on Oct 22 2026, 10:46am PDT. Interview question asked to Software Engineers interviewing at Hootsuite, Snowflake, Agoda and other companies. Original question asked: Find the K closest points to the origin.. Question last reported by a candidate interviewing at Blizzard for a Software Engineer interview on Oct 26 2026, 10:57pm PDT.