543. Diameter of Binary Tree

Practice Diameter of Binary Tree for free on NudgeCode: Easy, Binary Tree pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

The diameter of a binary tree is the number of edges on the longest path between any two nodes. That path may or may not pass through the root. Return the diameter.

Example

root = [1,2,3,4,5]  ->  3   (4 -> 2 -> 1 -> 3)

Constraints