Chef and Trees
CodeChefOpen on judge ↗
Chef recently read about trees. He already learnt that the trees are undirected, simple, connected graphs and has no cycles. He also knows that the tree (or graph) diameter is the largest distance of two nodes in the tree (or graph). He finds out about a challenging problem: Can we decrease the diameter of the tree if we add just a single edge? Unfortunately he is tired from a lot of reading, so c
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