Company: Linkedin_19_dec
Difficulty: medium
Minimize Total Travel Cost Problem Description Metro Land is a country located on a 2D plane. They are planning a summer festival for everyone in the country and would like to minimize the overall cost of travel for their citizens. Costs of travel are calculated as follows: A city is located at coordinates (x, y). The festival is located at coordinates (a, b). Cost of travel from a city to the festival = |x-a| + |y-b| per person. This is the Manhattan distance. The festival can be held at any integral location (a, b) in Metro Land. Find the optimal location for the festival, defined as the location with the minimal total travel cost assuming all people attend. Return this minimal total travel cost. The total travel cost for a festival at (a, b) is the sum of costs for all people from all cities: Σ ( numPeople[i] * ( |x[i]-a| + |y[i]-b| )) for all cities i . Example Given: numPeople = [1, 2] x = [1, 3] y = [1, 3] This means there is 1 person in City 0 located at (1, 1) and there a