TreeDFS
The diameter of a binary tree is the length (counted in edges) of the longest path between any two nodes. The path may or may not pass through the root. Find the diameter. Build the tree from the level-order input yourself, then solve the problem.
Input
A single line giving the tree in level order, with the word null for a missing child (for example 3 9 20 null null 15 7).
Output
Print the diameter, measured in edges.
Constraints
1 <= number of nodes <= 800
Example 1
Input
1 2 3 4 5
Output
3
The path 4 -> 2 -> 1 -> 3 (or 5 -> 2 -> 1 -> 3) has 3 edges.