We have a list A, of points(x,y) on the plane. Find the B closest points to the origin (0, 0).
Here, the distance between two points on a plane is the Euclidean distance.
You may return the answer in any order. The answer is guaranteed to be unique (except for the order that it is in.)
Note: Euclidean distance between two points P1(x1,y1) and P2(x2,y2) is sqrt( (x1-x2)^2 + (y1-y2)^2 ).
The argument given is list A and an integer B.
Return the B closest points to the origin (0, 0) in any order.
1 <= B <= length of the list A <= 100000 -100000 <= A[i] <= 100000 -100000 <= A[i] <= 100000
Input 1: A = [ [1, 3], [-2, 2] ] B = 1 Output 1: [ [-2, 2] ] Input 2: A =[ [3, 3], [5, -1], [-2, 4] ] B = 2 Output 2: [ [3, 3], [-2, 4] ]
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.