Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
For the node i, calculate the height of each of its children and keep the first and second maximum heights (max1_i , max2_i).
Check all nodes and return max( 2 + max1_i + max2_i ).