1515. Best Position for a Service Centre
Last updated
Last updated
https://leetcode.com/problems/best-position-for-a-service-centre
A delivery company wants to build a new service centre in a new city. The company knows the positions of all the customers in this city on a 2D-Map and wants to build the new centre in a position such that the sum of the euclidean distances to all customers is minimum.
Given an array positions
where positions[i] = [xi, yi]
is the position of the ith
customer on the map, return the minimum sum of the euclidean distances to all customers.
In other words, you need to choose the position of the service centre [xcentre, ycentre]
such that the following formula is minimized:
Answers within 10^-5
of the actual value will be accepted.
Example 1:
Example 2:
Example 3:
Example 4:
Example 5:
Constraints:
1 <= positions.length <= 50
positions[i].length == 2
0 <= positions[i][0], positions[i][1] <= 100