Fetching data...
This may take a moment
Back
1665. Diameter of N-Ary Tree
Medium
Tree
Depth-First Search
Solve on LeetCode
View Solutions
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 ).
Similar Questions
Diameter of Binary Tree
Easy
Statistics
Acceptance
75.4%
Submissions
80,552
Accepted
60,742