
[LeetCode] 133. Clone Graph, Medium

·
CodingTest/LeetCode
1. 문제val와 neighbors 필드를 가지는 노드로 구성된 그래프가 주어질 때, 이를 원래 노드를 참조하지 않는 새로운 노드로 구성된 그래프를 구성하라.2. 해결/** * Definition for _Node. * class _Node { * val: number * neighbors: _Node[] * * constructor(val?: number, neighbors?: _Node[]) { * this.val = (val===undefined ? 0 : val) * this.neighbors = (neighbors===undefined ? [] : neighbors) * } * } * */function DFS(node: _Node, ..