Practice Time Taken to Mark All Nodes
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
The pairs edges[i] = [u, v] connect nodes of an undirected tree, where n = edges.length + 1 and nodes are numbered 0 through n - 1. Once a neighbor is marked, an unmarked odd-numbered node takes one time unit to become marked, while an even-numbered node takes two. For each starting node i independently, mark only i at time 0 and return the time when every node has become marked. Return these times in node-index order.
Source: Time Taken to Mark All Nodes on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
edges = [[0,1],[0,2]]
[2,4,3]
# Example 2
edges = [[0,1]]
[1,2]
# Example 3
edges = [[2,4],[0,1],[2,3],[0,2]]
[4,6,3,5,5]
Constraints
Related LeetCode Problems
Practice more problems similar to Time Taken to Mark All Nodes.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.