Node Picking
CodeChefOpen on judge ↗
There is an unrooted tree, T, with L leaves and N nodes. (Leaves are nodes with degree = 1.) For every node u, we define its rootScore. To calculate rootScore(u), first root the tree at u (which might be a leaf node). We also define a coloring procedure for any rooted tree. First remove any existing color from all the nodes. Then select some nodes and apply the colorSubtree function on them. W
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start