Easy Implementation || BFS
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```cpp []\nclass Solution {\npublic:\n    vector<int> maxTargetNodes(vector<vector<int>>& edges1,\n                               vector<vector<int>>& edges2, int k) {\n        ios::sync_with_stdio(false);\n        cin.tie(0);\n        cout.tie(0);\n        vector<vector<int>> adj(4000, vector<int>());\n        int n = edges1.size(), m = edges2.size();\n        for (auto a : edges1) {\n            adj[a[0]].push_back(a[1]);\n            adj[a[1]].push_back(a[0]);\n        }\n        for (auto a : edges2) {\n            adj[2000 + a[0]].push_back(2000 + a[1]);\n            adj[2000 + a[1]].push_back(2000 + a[0]);\n        }\n        vector<int> temp(4000, 0);\n        for (int i = 0; i <= n; i++) {\n            queue<int> q;\n            q.push(i);\n            int l = 0;\n            vector<int> v(4000, 0);\n            v[i] = 1;\n            bool ch = false;\n            while (!q.empty()) {\n                int s = q.size();\n                for (int j = 0; j < s; j++) {\n                    int a = q.front();\n                    q.pop();\n                    if (l <= k)\n                        temp[i]++;\n                    else {\n                        ch = true;\n                        break;\n                    }\n                    for (auto c : adj[a]) {\n                        if (v[c] == 0) {\n                            q.push(c);\n                            v[c] = 1;\n                        }\n                    }\n                }\n                if (ch)\n                    break;\n                l++;\n            }\n        }\n        for (int i = 2000; i <= (2000 + m); i++) {\n            queue<int> q;\n            q.push(i);\n            int l = 0;\n            vector<int> v(4000, 0);\n            v[i] = 1;\n            bool ch = false;\n            while (!q.empty()) {\n                int s = q.size();\n                for (int j = 0; j < s; j++) {\n                    int a = q.front();\n                    q.pop();\n                    if (l <= k - 1)\n                        temp[i]++;\n                    else {\n                        ch = true;\n                        break;\n                    }\n                    for (auto c : adj[a]) {\n                        if (v[c] == 0) {\n                            q.push(c);\n                            v[c] = 1;\n                        }\n                    }\n                }\n                if (ch)\n                    break;\n                l++;\n            }\n        }\n        vector<int> ans;\n        int q = 0;\n        for (int j = 2000; j <= (2000 + m); j++) {\n            q = max(q, temp[j]);\n        }\n        for (int i = 0; i <= n; i++) {\n            int l = 0;\n            int p = temp[i];\n            l = p + q;\n            ans.push_back(l);\n        }\n        return ans;\n    }\n};\n```
['Breadth-First Search', 'Graph', 'C++']