Not so hard 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```csharp []\npublic class Solution {\n    public int[] MaxTargetNodes(int[][] e1, int[][] e2, int k) {\n    Dictionary <int, List<int>> d1= new   Dictionary <int, List<int>>();\n     Dictionary <int, List<int>> d2= new   Dictionary <int, List<int>>();\n     for(int i=0; i< e1.Length; i++){\n        if(d1.ContainsKey(e1[i][0]))d1[e1[i][0]].Add(e1[i][1]);\n        else d1.Add(e1[i][0], new List<int>(){e1[i][1]});\n         if(d1.ContainsKey(e1[i][1]))d1[e1[i][1]].Add(e1[i][0]);\n        else d1.Add(e1[i][1], new List<int>(){e1[i][0]});\n     }\n     for(int i=0; i< e2.Length; i++){\n        if(d2.ContainsKey(e2[i][0]))d2[e2[i][0]].Add(e2[i][1]);\n        else d2.Add(e2[i][0], new List<int>(){e2[i][1]});\n         if(d2.ContainsKey(e2[i][1]))d2[e2[i][1]].Add(e2[i][0]);\n        else d2.Add(e2[i][1], new List<int>(){e2[i][0]});\n     }\n    int[] a1= new int [e1.Length+1];\n     foreach(int a in d1.Keys){\n        bool[] seen= new bool[ e1.Length+1];\n        seen[a]=true;\n        Queue<int> q= new Queue<int>();\n        q.Enqueue(a);\n        int s=0;\n        while( q.Count>0 && s<k){\n            int l=q.Count;\n            for (int i=0; i<l; i++){\n                int x=q.Dequeue();\n                for(int j=0; j< d1[x].Count; j++){\n                    if(!seen[d1[x][j]]){\n                        seen[d1[x][j]]=true;\n                        a1[a]++;\n                        q.Enqueue(d1[x][j]);\n                    }\n                }\n            }\n            s++;\n        }\n     }\n     int[] a2= new int [e2.Length+1];\n     foreach(int a in d2.Keys){\n        bool[] seen= new bool[ e2.Length+1];\n        seen[a]=true;\n        Queue<int> q= new Queue<int>();\n        q.Enqueue(a);\n        int s=0;\n        while( q.Count>0 && s<k-1){\n            int l=q.Count;\n            for (int i=0; i<l; i++){\n                int x=q.Dequeue();\n                for(int j=0; j< d2[x].Count; j++){\n                    if(!seen[d2[x][j]]){\n                        seen[d2[x][j]]=true;\n                        a2[a]++;\n                        q.Enqueue(d2[x][j]);\n                    }\n                }\n            }\n            s++;\n        }\n     }\n     int max=0;\n     for (int i=0; i< a2.Length; i++){\n        max=Math.Max(max,a2[i] );\n           }\n     int []ans = new int[e1.Length+1];\n    if(k>0) for(int i=0; i< a1.Length; i++){\n        ans[i]=max+2+a1[i];\n     }\n     else Array.Fill(ans,1);\n     return ans;\n\n    }\n}\n```
['C#']