Not a fast solution || C++ || Just working
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    #define ll long long\n    ll check(vector<ll>adj[],vector<ll>&path,int n){\n        unordered_set<ll>ss(path.begin(),path.end());\n        ll answer=INT_MIN,m=path.size();\n        for(ll i=0;i<m;i++){\n            ll mayank=path[i],length=0;\n            vector<bool>visited(n);visited[mayank]=true;\n            queue<ll>q;q.push(mayank);\n            while(!q.empty()){\n                ll size=q.size();\n                while(size--){\n                    ll temp=q.front();q.pop();\n                    for(ll &x:adj[temp]){\n                        if(ss.find(x)!=ss.end() && visited[x]==false){\n                            visited[x]=true;\n                            q.push(x);\n                        }\n                    }\n                }\n                length++;\n            }\n            ll count=0;\n            for(ll j=0;j<n;j++){\n                if(visited[j]==true){\n                    count++;\n                }\n            }\n            if(count!=path.size()){\n                return -1;\n            }\n            else{\n                answer=max(answer,length-1);\n            }\n        }\n        return answer;\n    }\n\n    vector<int> countSubgraphsForEachDiameter(int n, vector<vector<int>>& edges) {\n        vector<ll>adj[n];\n        vector<int>answer(n-1,0);\n        for(auto &x:edges){\n            adj[x[0]-1].push_back(x[1]-1);\n            adj[x[1]-1].push_back(x[0]-1);\n        }\n        for(ll i=0;i<(1LL<<n);i++){\n            vector<ll>path;\n            for(ll j=0;j<n;j++){\n                if(i&(1LL<<j)){\n                    path.push_back(j);\n                }\n            }\n            if(path.size()<=1){\n                continue;\n            }\n            ll temp=check(adj,path,n);\n            if(temp!=-1){\n                answer[temp-1]++;\n            }\n        }\n        return answer;\n    }\n};\n```
['C++']