Diameter Of Binary Tree

Given a Binary Tree, find and return the diameter of input binary tree.

Diameter is - largest count of nodes between any two leaf nodes in the binary tree (both the leaf nodes are inclusive).

Input format :
Elements in level order form (separated by space)
(If any node does not have left or right child, take -1 in its place)
Output Format :
diameter
Sample Input :
8 3 10 1 6 -1 14 -1 -1 4 7 13 -1 -1 -1 -1 -1 -1 -1
Sample Output :
7

Comments

Popular posts from this blog

How to pass parameters in webhook?

Access and modify all the resources of our Wiki.js using WikiJS API

Fahrenheit to Celsius