Given a reference to a connected undirected graph, return a deep copy of the graph.
For the Cheetcode runner, graphs are represented as adjacency lists where index 1 maps to node 1.
Return a new adjacency list with the same structure rather than reusing the input object.
Model the relationships explicitly, then choose BFS, DFS, or union find based on the question. Track visited state so cycles do not create repeated work.
Examples
Input: adjList = [[2,4],[1,3],[2,4],[1,3]] Output: [[2,4],[1,3],[2,4],[1,3]]
Input: adjList = [[]] Output: [[]]
Constraints
- 0 <= number of nodes <= 100
- 1 <= node values <= 100
- No self-loops or repeated edges.