There are n cities numbered from 0 to n - 1 and n - 1 roads. You need to reorient some roads such that each city can visit the city 0. Return the minimum number of edges changed.
{
"n": 6,
"connections": [
[
0,
1
],
[
1,
3
],
[
2,
3
],
[
4,
0
],
[
4,
5
]
]
}3{
"n": 5,
"connections": [
[
1,
0
],
[
1,
2
],
[
3,
2
],
[
3,
4
]
]
}2{
"n": 3,
"connections": [
[
1,
0
],
[
2,
0
]
]
}0Sign in to Run Code and Submit