ShareChat | OA | HackerEarth | SDE-1 | Maximum Diameter
Anonymous User
3171

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:

  • First line: T denoting the number of test cases
    For each test case:
    • First line: Integer N
    • Second line: N space seperated integers

Output format:

  • For every test case, print the value of the maximum diameter in a new line.

Constraints:
1 <= T <= 100
1 <= N <= 100
1 <= CNT[i] <= 1000

Sample input :

1
1
3

Sample output :

2
Comments (5)