Question: Imagine you have a map displaying various cities represented by coordinates on a 2 D - plane, with each pair ( xi , yi )

Imagine you have a map displaying various cities represented by coordinates
on a 2D-plane, with each pair (xi, yi) in an array points indicating the location of a city. You are planning to establish flight routes between these cities.
The fuel required to set up a flight route between any two cities depends on their re-spective positions on the map.Return the minimum fuel required to connect all locations on the map. All locations are connected if there is exactly one simple path between any two locations.
Constraints:
1<= points.length <=1000
10^6<= xi
, yi <=10^6
All pairs (xi, yi) are distinct.
Input :
locations =[[0,0],[2,2],[3,10],[5,2],[7,0]]
Output :
20
Explanation:
We can connect the points as shown above to get the minimum cost of 20.
Input :
locations =[[3,12],[2,5],[4,1]]
Output :
18

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!