Morgan Stanley Interview Question

The questions in algorithm were difficult. Like find the shortest path between 2 connected component in the matrix