Given a reference of a node in a connected undirected graph, return a deep copy (clone) of the graph. The graph is represented as an adjacency list: a list of lists where `adjList[i]` contains the 1-indexed neighbors of node `i + 1`. For example, `[[2,4],[1,3],[2,4],[1,3]]` means node 1 connects to nodes 2 and 4, node 2 connects to nodes 1 and 3, and so on. Return the adjacency list of the cloned graph (same structure as the input). If the input is an empty list `[]`, return `[]`.
Example 1
Input: adjList = [[2,4],[1,3],[2,4],[1,3]]
Output: [[2,4],[1,3],[2,4],[1,3]]
Explanation: The graph is the square 1-2-3-4-1. The clone has four new nodes with exactly the same connections, so its adjacency list matches the input.
Example 2
Input: adjList = [[]]
Output: [[]]
Explanation: The graph is a single node with no neighbours, so the clone is also one node with no neighbours.
Example 3
Input: adjList = []
Output: []
Explanation: The graph is empty, so there is nothing to clone.
Use BFS with a hash map to track which nodes have been cloned. Process each node level by level, copying its neighbors. The hash map maps old node indices to their cloned neighbor lists.
Run checks all cases above. Submit evaluates all test cases.