jeudi 26 novembre 2020

Maximum Diameter [closed]

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 a tree.

#include<bits/stdc++.h>
using namespace std;
 
int Max_dia (int N, vector<int> CNT_i) {
   // Write your code here
   
}
 
int main() {

    int T;
    cin >> T;
    for(int t_i = 0; t_i < T; t_i++)
    {
        int N;
        cin >> N;
        vector<int> CNT_i(N);
        for(int i_CNT_i = 0; i_CNT_i < N; i_CNT_i++)
        {
            cin >> CNT_i[i_CNT_i];
        }
 
        int out_;
        out_ = Max_dia(N, CNT_i);
        cout << out_;
        cout << "\n";
    }
}

Aucun commentaire:

Enregistrer un commentaire