Return the diameter of an N-ary tree (length of the longest path between any two nodes).
Given the root of an N-ary tree, find the diameter of the tree. The diameter is the length of the longest path between any two nodes in the tree. The path does not necessarily need to go through the root.
Examples
Input:[1,[[2,[]],[3,[]],[4,[]]]]
Output:2
Input:[1,[[2,[]],[3,[]]]]
Output:2
Hints
Use DFS to compute the height of each subtree.
For each node, the longest path through it = sum of two largest child heights + 1.