Problem
You get one node of a connected undirected graph. A connected graph has a path between each pair of nodes. Each node is an object of the class Node with an integer val and a list neighbors.
Return a deep copy of the graph. A deep copy has new node objects with the same values and the same edges. The copy must not use a node of the original graph. Keep the neighbors of each node in the same order.
The examples show the graph as an adjacency list adjList. An adjacency list gives the neighbors of each node. The node with the value i has the neighbor values adjList[i - 1].
You always get the node with the value 1, and you return its copy. If adjList is empty, the graph has no nodes. Then you get None and you return None.
Example 1
- Input:
- adjList = [[2,3],[1,3],[1,2]]
- Output:
- [[2,3],[1,3],[1,2]]
- Explanation:
- The graph has 3 nodes, and each node connects to the other two nodes. The copy has 3 new nodes with the same edges.
Example 2
- Input:
- adjList = [[]]
- Output:
- [[]]
- Explanation:
- The graph has one node with the value 1 and no edges.
Example 3
- Input:
- adjList = []
- Output:
- []
- Explanation:
- The graph has no nodes, so the copy is also empty.
Constraints
- 0 <= number of nodes <= 100
- 1 <= Node.val <= 100
- Node.val is unique for each node
- The graph has no repeated edges and no self-loops
- The graph is connected
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 2 records
LinkedIn
Leetcode 133. Clone Graph
Reported Dec 17, 2025 · 1 source report
JUNIOR
Source snapshot: Nov 12, 2026
View sourceMeta
Leetcode 133. Clone Graph
Reported Apr 21, 2026 · 10 source reports
MID_LEVEL, SENIOR, STAFF
Source snapshot: Nov 12, 2026
View source