Clone Graph Problem
Clone Graph Problem — ExecCode Medium DSA Practice
Solve the Clone Graph problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Given a reference of a node in a connected undirected graph, return a deep copy (clone) of the graph. Each node contains a value and a list of neighbors.
Examples
Input adjList = [[2,4],[1,3],[2,4],[1,3]]; Output [[2,4],[1,3],[2,4],[1,3]]. Input adjList = [[]]; Output [[]]. Input adjList = [[2],[1]]; Output [[2],[1]]
Constraints
The number of nodes in the graph is in the range [0, 100]. 1 ≤ Node.val ≤ 100 Node.val is unique for each node. There are no repeated edges and no self-loops.
Practice Clone Graph free on ExecCode. Browse DSA problems, topic map, and placement guides.