Python || Simple Solution || BFS || 100% beats
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\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(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, m = len(edges1) + 1, len(edges2) + 1\n        if k == 0:\n            return [1] * (n)\n        t1 = defaultdict(list)\n        t2 = defaultdict(list)\n        for i in edges1:\n            [st, ed] = i\n            t1[st].append(ed)\n            t1[ed].append(st)\n        for i in edges2:\n            [st, ed] = i\n            t2[st].append(ed)\n            t2[ed].append(st)\n\n\n        def helper2(node, k):\n            self.s.add(node)\n            if k == 0:\n                return 1\n            sm = 1\n            for i in t2[node]:\n                if i not in self.s:\n                    sm += helper2(i, k - 1)\n            return sm\n\n        \n        def helper1(node, k):\n            self.s.add(node)\n            if k == 0:\n                return 1\n            sm = 1\n            for i in t1[node]:\n                if i not in self.s:\n                    sm += helper1(i, k - 1)\n            return sm\n\n        mx = -math.inf\n        for i in range(m):\n            self.s = set()\n            mx = max(mx, helper2(i, k - 1))\n\n        ans = [0] * n\n        for i in range(n):\n            self.s = set()\n            val = helper1(i, k)\n            ans[i] = val + mx\n        return ans\n```
['Breadth-First Search', 'Python3']