USING BFS  in both trees
Intuition\n Describe your first thoughts on how to solve this problem. \nUSING BFS in both tree to count node at distance k in tree1 and  maximum number of node
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUSING BFS in both tree to count node at distance k in tree1 and  maximum number of node at distance k-1 in tree 2 .\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(V.(V+E))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(V+E)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    // int s;\n    int solve(unordered_map<int, vector<int>>& adj, int start, int k, int s) {\n        queue<int> q;\n        vector<int> vis(s + 1, 0);\n        int cnt = 0;\n        q.push(start);\n        int dist = 0;\n        vis[start] = 1;\n\n        while (!q.empty() and dist <= k) {\n            int n = q.size();\n\n            for (int i = 0; i < n; i++) {\n\n                auto it = q.front();\n                q.pop();\n\n                int node = it;\n\n                cnt++;\n\n                for (auto adjNode : adj[node]) {\n                    if (!vis[adjNode]) {\n                        q.push(adjNode);\n                        vis[adjNode] = 1;\n                    }\n                }\n            }\n            dist++;\n        }\n        return cnt;\n    }\n    vector<int> maxTargetNodes(vector<vector<int>>& edges1,\n                               vector<vector<int>>& edges2, int k) {\n        unordered_map<int, vector<int>> adj1;\n        unordered_map<int, vector<int>> adj2;\n\n        int n1 = edges1.size();\n        int n2 = edges2.size();\n\n        vector<int> temp1;\n        vector<int> ans;\n        int maxi = INT_MIN;\n\n        for (int i = 0; i < n1; i++) {\n            int u = edges1[i][0];\n            int v = edges1[i][1];\n\n            adj1[u].push_back(v);\n            adj1[v].push_back(u);\n        }\n\n        for (int i = 0; i < n2; i++) {\n            int u = edges2[i][0];\n            int v = edges2[i][1];\n\n            adj2[u].push_back(v);\n            adj2[v].push_back(u);\n        }\n\n        for (int i = 0; i < adj1.size(); i++) {\n            int cnt = solve(adj1, i, k, adj1.size());\n            temp1.push_back(cnt);\n        }\n\n        for (int i = 0; i < adj2.size(); i++) {\n\n            int cnt = solve(adj2, i, k - 1, adj2.size());\n            maxi = max(maxi, cnt);\n        }\n\n        for (int i = 0; i < adj1.size(); i++) {\n            ans.push_back(temp1[i] + maxi);\n        }\n        return ans;\n    }\n};\n```
['Tree', 'Breadth-First Search', 'Graph', 'C++']