Algorithm · Snapchat · Medium
You are given a two-dimensional integer array points, where points[i] = [xi, yi] denotes a location in the Cartesian plane, along with an integer K. Return the K locations whose Euclidean distances from (0,0) are smallest. Requirements: The algorithm must have a time complexity of O(N log K). When two or more points are equally far from the origin, their relative ordering may be arbitrary. Input (stdin) First line: an integer N, representing the total number of points The…
Checking your access…