Given the root of a binary tree, return the length of the diameter of the tree — the length (in edges) of the longest path between any two nodes, which may or may not pass through the root.
Input: root = [1,2,3,4,5]
Output: 3
Topics: trees
Asked by: Amazon, Meta, Microsoft
Time complexity: O(n). Space complexity: O(h).