Given the rootNode
of a multi-child tree, your task is to find the length of the longest path between any two nodes in the tree.
This longest path is referred to as the diameter of the tree, and it does not necessarily have to pass through the root node.
(The tree is represented in level order format where each group of children is separated by a null value.)
Example 1:
Input: rootNode = [1,null,4,2,5,null,7,8] Output: 3 Explanation: The diameter path length is 3.
Example 2:
Input: rootNode = [1,null,3,null,4,5,null,6,null,7] Output: 4
Example 3:
Input: rootNode = [1,null,2,4,6,7,null,null,8,9,null,10,null,11,null,null,12,null,13,null,null,14] Output: 7