1665. Diameter of N-Ary Tree

Medium
Tree
Depth-First Search

Description

Hints

Hint 1
For the node i, calculate the height of each of its children and keep the first and second maximum heights (max1_i , max2_i).
Hint 2
Check all nodes and return max( 2 + max1_i + max2_i ).

Statistics

Acceptance
75.4%
Submissions
80,552
Accepted
60,742