4 4 1 2 2 3 3 4 1 3
For this input, the required output is 0 1 1 2.
0 1 1 2
3 2 1 2 2 3
For this input, the required output is 0 1 2.
0 1 2
4 2 1 2 3 4
For this input, the required output is 0 1 -1 -1.
0 1 -1 -1
Given an unweighted undirected graph with nnn vertices and mmm edges, find the shortest distance from vertex 111 to all other vertices.
If a vertex is unreachable from vertex 111, output −1-1−1 for that vertex.