Hash Table
133. Clone Graph
Deep-copy a graph that may have cycles. The naive "make a new node, then copy its neighbours" recurses forever the moment it hits a cycle — copying node 1 copies node 2 copies node 1 copies… The fix…
Loading…
Deep-copy a graph that may have cycles. The naive "make a new node, then copy its neighbours" recurses forever the moment it hits a cycle — copying node 1 copies node 2 copies node 1 copies… The fix…
Loading…