Harpreet's Newsletter

Harpreet's Newsletter

K Closest Points to Origin

TikTok Interview Question

Harpreet Singh's avatar
Harpreet Singh
Feb 23, 2026
∙ Paid

Problem Overview

Difficulty: Medium
LeetCode Pattern: Heap

Given an array of points where points[i] = [xi, yi] and an integer k, return the k closest points to the origin (0, 0).

Note: Euclidean Distance To Origin = √(x² + y²)

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

Output: 
· [[-2,2]]

Explanation:
· [1,3] dist to origin = √10
· [-2,2] dist to origin = √…
User's avatar

Continue reading this post for free, courtesy of Harpreet Singh.

Or purchase a paid subscription.
© 2026 Harpreet Singh · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture