Diameter of Tree
CodeChefOpen on judge ↗
Santa loves trees . So Banta gifted him a tree having N nodes numbered from 1 to N on his birthday .Santa has recently learnt how to calculate diameter of a tree . Diameter of a tree is defined as the longest path in a tree . The length of a path between 2 nodes u and v is defined as the number of edges in the path between u and v .Being inquisitive , he wonders what is the maximum value of diamet
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