Hard35 min
Depth of a Tree
Return the number of nodes along the longest path from the root to a leaf. Null represents an empty tree.
Your function
Implement solve(value, extra) in JavaScript. Return the answer; printing alone does not count as a result.
Examples
Input:
[{"value":1,"left":{"value":2,"left":null,"right":null},"right":null}]Output:
2Input:
[null]Output:
0Constraints
Input contains at most 1,000 values or characters. Numbers are finite integers. Inputs follow the structure shown in the examples.