10048

 

280

This also can be solved using bfs or dfs.

 

10724

 

247

 

10793

 

10075

Theory: Distance This uses the ‘haversine’ formula to calculate the great-circle distance between two points – that is, the shortest distance over the earth’s surface – giving an ‘as-the-crow-flies’ distance between the points (ignoring any hills they fly over, of course!). Haversine formula: a = sin²(Δφ/2) + cos φ1 * cos φ2 * sin²(Δλ/2) c = 2

10171

 

10269

This can be done two ways using floyed-warshall algorithm and also using bfs; Floyed warshall:

BFS:

 

104

 

423