DFS recursive python. As simple as possible, hopefully it helps others : )
Intuition\n- Find the number of targets for each node in graph1 (for k)\n- Find the number of targets for each node in graph2 (for k-1 since we use one edge to 
# Intuition\n- Find the number of targets for each node in graph1 (for k)\n- Find the number of targets for each node in graph2 (for k-1 since we use one edge to connect graph1 to graph2)\n- We only care about the max number from graph2 since we will always connect graph1 to that node.\n\n\n(using extra space helped with debugging)\n\n\n# Code\n```python3 []\nclass Solution:\n    def maxTargetNodes(self, edges1: List[List[int]], edges2: List[List[int]], k: int) -> List[int]:\n\n        # Recursively get the number of targets from \'node\' \n        def getNumTargets(node, parent, adj, k) -> int:\n            if k <= 0:\n                return 1\n\n            count = 1\n            for nei in adj[node]:\n                if nei != parent:\n                    count += getNumTargets(nei, node, adj, k-1)\n            return count\n\n        # Create graph \n        def getGraph(edges):\n            adj = collections.defaultdict(list)\n            for u, v in edges:\n                adj[u].append(v)\n                adj[v].append(u)\n            return adj\n\n\n        # Handle edge case\n        if k == 0: return [1] * (len(edges1)+1)\n\n        # Process Graph 1\n        adj1 = getGraph(edges1)\n        targets1 = {node: getNumTargets(node, -1, adj1, k) for node in adj1}\n            \n        # Process graph2, use k-1 since the connection from graph1 to graph2 takes one edge\n        adj2 = getGraph(edges2)\n        targets2 = {node: getNumTargets(node, -1, adj2, k - 1) for node in adj2}\n\n        maxNumTargets2 = max(targets2.values())\n        return [targets1[i] + maxNumTargets2 for i in range(len(edges1)+1)]\n        \n```
['Python3']