10307 - Killing Aliens in Borg Maze


Difficulty : medium

Solution Description :
BFS and MST problem

1. First find the distance between each A and S using BFS.
i.e.
#####
#A#A##
# # A#
#S  ##
##### 
Suppose A: Node 1, A: Node 2, A: Node 3, and S: node 4
Distance list:
1 -> 4 : 2
1 -> 2 : 6
1 -> 3 : 6
2 -> 3 : 2
2 -> 4 : 4
2 -> 1 : 6
3 -> 2 : 2
3 -> 4 : 4
3 -> 1 : 6
4 -> 1 : 2
4 -> 2 : 4
4 -> 3 : 4

2. After find distance run MST(kruskal) algorithm for find ans.