#187Medium#18 in Nutanix's list· asked at 10 companies
Clone Graph
Hosted on LeetCode
Solve it on LeetCode, track it here.
This problem's full statement lives on LeetCode. Open it in a new tab, then come back to mark it solved, add notes and keep your streak.
LeetCode Premium locked?
Most company-tagged LeetCode problems are behind Premium. If you have ChatGPT Plus or Claude Pro, ask it for the full statement, examples and constraints. The buttons below open a chat with the prompt already filled in.
What we know
Example 1
Input: adjList = [[2,4],[1,3],[2,4],[1,3]] Output: [[2,4],[1,3],[2,4],[1,3]]
Node 1 connects to 2 and 4, node 2 to 1 and 3, and so on.
Example 2
Input: adjList = [[]] Output: [[]]
A single node with no neighbours.
Example 3
Input: adjList = [] Output: []
The graph is empty.
Constraints
- •
The number of nodes in the graph is in the range
[0, 100]. - •
1 <= Node.val <= 100 - •
Node.valis unique for each node. - •
The graph is connected and has no repeated edges or self-loops.