Back to course home
0% completed
Clone Graph (medium)
Problem Statement
Given a reference of a node in a connected undirected graph, return a deep copy (clone) of the graph. Each node in the graph contains a value (int
) and a list (List[Node]
) of its neighbors.
Example 1:
Input:
1--2
| |
4--3
Expected Output:
1--2
| |
4--3
Explanation: The graph has four nodes with the following connections:
- Node
1
is connected to nodes2
and4
. - Node
2
is connected to nodes1
and3
. - Node
3
is connected to nodes2
and4
. - Node
4
is connected to nodes1
and3
.
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible