Quick Overview

Return the k points closest to a two-dimensional query location with deterministic distance and coordinate tie breaks. Avoid square roots and use a size-k max-heap to achieve O(n log k) time and O(k) space when k is small.

Find the K Closest Points to a Query Location

Company: Uber

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Overview: Return the k points closest to a two-dimensional query location with deterministic distance and coordinate tie breaks. Avoid square roots and use a size-k max-heap to achieve O(n log k) time and O(k) space when k is small.

Read the full Uber Software Engineer interview experience this question came from

Loading…