Question
Metro Land is a country located on a 2D Plane. They are having asummer festival for everyone in the country and would like tominimize the
Metro Land is a country located on a 2D Plane. They are having asummer festival for everyone in the country and would like tominimize the overall cost of travel for their citizens. Costs oftravel are calculated as follows:
1) A city is located at coordinates(x,y)
2) The festival is located at coordinates(a,b)
3) cost of travel from a city to the festival = |x - a| + |y -b| per person
The festival can be held at any location in Metro-land. Find theoptimal location for the festival, defined as the location with theminimal total travel cost assuming all people attend. Determine thetotal cost of travel for all citizens to go to the festival at thatlocation.
Example: numsPeople:[1, 2], x = [1, 3], y = [1, 3]. The lowesttotal cost to travel is if the event is held at grid position(3 ,3) at cost of 4.
See this link has more details:https://codingee.com/metro-land-hacker-rank/
Metro Land is a country located on a 2D plane. They are having 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-bl per person. The festival can be held at any location in Metro Land. Find the optimal location for the festival, defined as the location with the minimal total travel cost assuming all people attend. Determine the total cost of travel for all citizens to go to the festival at that location. Example numPeople = [1, 2] x = [1, 3] y = [1,3] There is 1 person in City 0 located at (x[0], y[0]) = (1, 1) and there are 2 people in City 1 at (x[1], y[1]) =(3, 3). If the location for the festival is at (2, 2):
Step by Step Solution
3.53 Rating (170 Votes )
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started