New update is available. Click here to update.

Posted: 11 Mar, 2021

Difficulty: Hard

```
The first line of input contains an integer 'T', the number of test cases.
The first line of the test case contains a single integer ‘N’.
From the second line onwards next 'N-1' lines denote the edges of the graph.
Each edge is characterized by two integers 'A' and 'B' where 'A' and 'B' denote the endpoints of the edge. The edges[i][0], edges[i][1] contains the endpoints of edges.
```

```
For each test case, return the list where the ith element denotes the distance of the ith vertex from all others vertices.
```

```
You are not required to print the expected output; it has already been taken care of. Just implement the function.
```

```
1 <= T <= 50
1 <= N <= 10^3
0 <= edges[i][0], edges[i][1] <= N-1
Total number of edges = N-1
Time Limit: 1 sec
```

SIMILAR PROBLEMS

COUNT ISLANDS

Posted: 14 Sep, 2022

Difficulty: Moderate

Capturing Grid

Posted: 14 Sep, 2022

Difficulty: Moderate

The Summit

Posted: 15 Sep, 2022

Difficulty: Easy

Rotting Oranges

Posted: 15 Sep, 2022

Difficulty: Moderate

Distance to a Cycle in Undirected Graph

Posted: 7 Nov, 2022

Difficulty: Moderate

Categories:

Popular Courses: