PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Snapchat

Find K Nearest Points

Last updated: Apr 22, 2026

Quick Overview

This question evaluates proficiency with Euclidean distance metrics, selection algorithms, and efficient data structures for partial sorting, while requiring reasoning about algorithmic time and space complexity (the follow-up specifies O(n log k) time and O(k) extra space).

  • medium
  • Snapchat
  • Coding & Algorithms
  • Machine Learning Engineer

Find K Nearest Points

Company: Snapchat

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Given an array of 2D points `points`, where `points[i] = [x_i, y_i]`, and an integer `k`, return any `k` points whose Euclidean distance to the origin `(0, 0)` is smallest. If multiple answers are valid, return them in any order. Follow-up: design a solution with time complexity `O(n log k)` and `O(k)` extra space beyond the output.

Quick Answer: This question evaluates proficiency with Euclidean distance metrics, selection algorithms, and efficient data structures for partial sorting, while requiring reasoning about algorithmic time and space complexity (the follow-up specifies O(n log k) time and O(k) extra space).

Related Interview Questions

  • Determine Whether Courses Can Be Completed - Snapchat (medium)
  • Solve Decimal Coin Change - Snapchat (medium)
  • Find Maximum Island Perimeter - Snapchat (medium)
  • Solve Three Algorithmic Tasks - Snapchat (hard)
  • Implement a Timestamped Counter - Snapchat (medium)
Snapchat logo
Snapchat
Feb 2, 2026, 12:00 AM
Machine Learning Engineer
Onsite
Coding & Algorithms
0
0
Loading...

Given an array of 2D points points, where points[i] = [x_i, y_i], and an integer k, return any k points whose Euclidean distance to the origin (0, 0) is smallest. If multiple answers are valid, return them in any order.

Follow-up: design a solution with time complexity O(n log k) and O(k) extra space beyond the output.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Snapchat•More Machine Learning Engineer•Snapchat Machine Learning Engineer•Snapchat Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.