133. Clone Graph
Practice Clone Graph for free on NudgeCode: Medium, Graph pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Given a reference to one node of a connected undirected graph, return a deep copy of the whole graph. Every node has a val and a list of neighbors.
In the tests the graph is an adjacency list: node i has value i + 1, and you receive node 1. Returning any of the original nodes fails the test.
Example
adjList = [[2,4],[1,3],[2,4],[1,3]] -> [[2,4],[1,3],[2,4],[1,3]]
Constraints
- 0 <= number of nodes <= 100