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