Position: SDE 1 Backend
YoE: 1 year 3 months
Maximum Diameter
You are given a tree of N+1 levels from 0 to N. There is only one node at the level 0 that is called as root. There is an array CNT of size N where CNT[i] denotes the number of nodes at ith level. You have to find the maximum diameter possible in such a tree.
Note: Diameter is the number of edges in the longest path of the tree.
Input fomat:
T denoting the number of test casesNN space seperated integersOutput format:
Constraints:
1 <= T <= 100
1 <= N <= 100
1 <= CNT[i] <= 1000
Sample input :
1
1
3Sample output :
2