Maximum Diameter of a tree

given an array count where count[i] denotes the number of nodes present at the ith level. We need to output the maximum diameter(number of edges in the longest path) possible for this tree.

input :arr[]={2}
output :2

How to solve this ?

Hey @vaishnavtannu
Is this a madeup question ?If its not then please explain your testcase as well.

I encountered this question on leetcode discussion forum. Even I am unable to understand the testcase well and approach to solve this.

But still, I think, arr[] = {2} means there are two nodes in level next to root. So there are two edges and hence diameter is 2.

According to me this question is wrong because according to test case given
. q
q q Diametre is no of nodes so answer should be 3
If you came across a well-formulated question of this type then let me know.

arr[] = {2} means there are two nodes in level next to root. So there are two edges and hence diameter is 2.