You are given an undirected tree with n vertices labeled from
At each step, the frog follows these rules:
Move to an unvisited neighbor:
If the frog has unvisited neighbors, it jumps to one of them, chosen uniformly at random (equal probability for each choice).
No revisiting:
The frog can not jump back to a vertex it has already visited.
Stay when stuck
The frog will keep jumping at its current vertex if there are no unvisited neighbors.
The tree is represented as an array of edges, where edges[i] = [t seconds, the frog is on the vertex target.
Note: Your answer will be accepted if its absolute difference from the actual value is at most
.
Constraints:
1 n
edges.length ==
edges[i].length == 2
n
t
target n
You are given an undirected tree with n vertices labeled from
At each step, the frog follows these rules:
Move to an unvisited neighbor:
If the frog has unvisited neighbors, it jumps to one of them, chosen uniformly at random (equal probability for each choice).
No revisiting:
The frog can not jump back to a vertex it has already visited.
Stay when stuck
The frog will keep jumping at its current vertex if there are no unvisited neighbors.
The tree is represented as an array of edges, where edges[i] = [t seconds, the frog is on the vertex target.
Note: Your answer will be accepted if its absolute difference from the actual value is at most
.
Constraints:
1 n
edges.length ==
edges[i].length == 2
n
t
target n