Skip to main content
Clone Graph | AlgoCracked
AlgoCracked
ProblemsClone Graph
Medium54.0% acceptance
Blind75Hash TableDfsBfsGraph

Clone Graph

Given a reference to a node in a connected, undirected graph, return a deep copy (clone). Each node holds a value and a list of neighbors. The clone must consist entirely of new nodes. Node is predefined with val and neighbors . Input format The graph is given as an adjacency list where entry i lists the (1-indexed) neighbors of node i+1 , e.g. [[[2,4],[1,3],[2,4],[1,3]]] . The harness builds it, clones from node 1, and re-serializes the clone as an adjacency list.

Loading workspace…