InterviewDB Question

Points Search: Find the K Nearest Points to an Origin Using a Priority Queue

Question Details

Problem Given an array of 2D points and an integer k, return the k points closest to the origin (0, 0). Distance is Euclidean. The result can be in any order. Example: Round 1 - Coding Implement a solution using a max-heap of size k. Follow-ups What is the time complexity of the heap approach vs. a full sort? When does each become preferable? How would you use the Quickselect algorithm to achieve average O(n) time? If points arrive as a stream and you must always return the current k closest, ho…

Full Details

🔒

Unlock all Applied Intuition questions

Full insider details, leaked discussions, and candidate experiences.

Get full access — $100 a year, unlimited access

About This Question

This is a reported interview question from a applied intuition interview during the phone round.

It covers the following topics: Heap, Phone, Coding, Queue, Arrays, Onsite .