Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

Find the k post offices located closest to you, given your location and a list of locations of all post offices

Find the k post offices located closest to you, given your location and a list of locations of all post offices

available.

Locations are given in 2D coordinates in [X, Y], where X and Y are integers.

Euclidean distance is applied to find the distance between you and a post office.

Assume your location is [m, n] and the location of a post office is [p, q], the Euclidean distance between the office and you is SquareRoot((m – p) * (m – p) + (n – q) * (n – q)).

K is a positive integer much smaller than the given number of post offices.

Input

you: [0, 0]

post_offices: [[-16, 5], [-1, 2], [4, 3], [10, -2], [0, 3], [-5, -9]]

k = 3

Output

[[-1, 2], [0, 3], [4, 3]].

Java language

Thank you

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"