Easy Java Solution
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```java []\nclass Solution {\n    public int dfs(List<List<Integer>> adj,int i,int par,int k){\n        if(k<0) return 0;\n        int c=1;\n        for(int j:adj.get(i)){\n            if(j!=par) c+=dfs(adj,j,i,k-1);\n        }\n        return c;\n    }\n    public int[] find(int edges[][],int k){\n        int n=edges.length+1;\n        List<List<Integer>> adj=new ArrayList<>();\n        for(int i=0;i<n;i++) adj.add(new ArrayList<>());\n        for(int i[]:edges){\n            adj.get(i[0]).add(i[1]);\n            adj.get(i[1]).add(i[0]);\n        }\n        int ans[]=new int[n];\n        for(int i=0;i<n;i++){\n            int c=dfs(adj,i,-1,k);\n            ans[i]=c;\n        }\n        return ans;\n    }\n    public int[] maxTargetNodes(int[][] edges1, int[][] edges2, int k) {\n        int c1[]=find(edges1,k);\n        int c2[]=find(edges2,k-1);\n        int max=Arrays.stream(c2).max().getAsInt();\n        for(int i=0;i<c1.length;i++) c1[i]+=max;\n        return c1;\n    }\n}\n```
['Depth-First Search', 'Java']