Problem Challenge 1

We'll cover the following

Tree Diameter (medium) #

Given a binary tree, find the length of its diameter. The diameter of a tree is the number of nodes on the longest path between any two leaf nodes. The diameter of a tree may or may not pass through the root.

Note: You can always assume that there are at least two leaf nodes in the given tree.

Created with Fabric.js 1.6.0-rc.1 Example 1: 1 2 3 4 5 6 Output: 5Explaination: The diameter of the tree is: [4, 2, 1, 3, 6]
Created with Fabric.js 1.6.0-rc.1 Example 2: 1 2 3 5 6 7 8 10 9 11 Output: 7Explaination: The diameter of the tree is: [10, 8, 5, 3, 6, 9, 11]

Try it yourself #

Try solving this question here:

Output

0.747s

Tree Diameter: -1 Tree Diameter: -1

Mark as Completed
←    Back
Count Paths for a Sum (medium)
Next    →
Solution Review: Problem Challenge 1