Google | Onsite | Minimize the distance to the farthest point
11298
May 02, 2019
Jul 24, 2019
This question was asked in Google interview.
Assume you're looking to move, and have a set of amenities that you want to have easy access to from your new home. You have found a neighborhood you like, each block of which has zero or more amenities. How would you pick the block to live in such that the farthest distance to any amenity in your list is minimized?
Example:
Say your list contains {school, grocery}, and the blocks are as follows:
1: restaurant, grocery
2: movie theater
3: school
4:
5: school
The ideal choice would be block 2, such that the distances to the grocery and the nearest school are 1 each. Living on block 1 or 3 would make one of the distances zero, but the other one 2.
Comments (15)


