BFS javascript
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```javascript []\n/**\n * @param {number[][]} edges1\n * @param {number[][]} edges2\n * @param {number} k\n * @return {number[]}\n */\n var bfs=function(adj,n,k,start){\n    let queue=[];\n    queue.push(start);\n    let visited = Array.from({ length: n }, () => false);\n    visited[start]=true;\n\n    let cnt=0,d=0;\n    while(queue.length && d<=k){\n        let sz=queue.length;\n        while(sz-->0)\n          {\n            let node = queue.shift();\n            cnt++;\n            for (let n of adj[node]) {\n                 if (!visited[n]) {\n                     visited[n] = true;\n                     queue.push(n);\n                 }\n            }\n        }\n        d++;\n       \n    }\n    return cnt;\n\n }\nvar maxTargetNodes = function(edges1, edges2, k) {\n    const n = edges1.length + 1;\n    const m = edges2.length + 1;\n\n    const adj1 = Array.from({ length: n }, () => []);\n    const adj2 = Array.from({ length: m }, () => []);\n\n    for (const [u, v] of edges1) {\n      adj1[u].push(v);\n      adj1[v].push(u);\n    }\n    for (const [u, v] of edges2) {\n      adj2[u].push(v);\n      adj2[v].push(u);\n    } \n\n    \n\n\n\n    const good1 = new Array(n).fill(0);\n    const good2 = new Array(m).fill(0);\n    for(let i=0;i<n;i++)\n    good1[i]=bfs(adj1,n,k,i)\n\n    let ans = 0;\n\n    for(let i=0;i<m;i++)\n    ans=Math.max(ans,bfs(adj2,m,k-1,i));\n    for(let i=0;i<n;i++)\n    good1[i]+=ans;\n   return good1;\n\n\n\n};\n```
['Breadth-First Search', 'JavaScript']