Hello everyone!
In this blog, I will describe an (O(n)) construction for E. Building a Tree.
The main ideas are:
- checking the valid range of (k);
- rooting the tree at vertex (1);
- separating even and odd vertices into two branches;
- reducing the required distance sum to a depth sum;
- greedily assigning depths.







