Given a binary tree (level-order with null for missing nodes), return its diameter — the number of edges on the longest path between any two nodes. The input is JSON {tree}.
Input: JSON {tree}.
Output: Integer — the diameter in edges.
Input: {"tree":[1,2,3,4,5]}
Output: 3
Explanation: Path 4-2-1-3 (or 5-2-1-3).Input: {"tree":[1,2]}
Output: 1
Explanation: One edge.Input: {"tree":[1]}
Output: 0
Explanation: Single node.1<=nodes<=10^4