PrajaktaSathe / Java

Includes programs written in Java. You are welcome to contribute here!
59 stars 92 forks source link

K closest Point to Origin by Heap #169

Open AnushreeDixit opened 1 year ago

AnushreeDixit commented 1 year ago

Heap

Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0). The distance between two points on the X-Y plane is the Euclidean distance (i.e., √(x1 - x2)^2 + (y1 - y2)^2). Example : Input: points = [[1,3],[-2,2]], k = 1 Output: [[-2,2]]