-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
Bug Report for https://neetcode.io/problems/clone-graph
Looks like this problem for some reason can't be solved using c#, here is my solution: public class Solution {
public Node CloneGraph(Node node)
{
if (node == null) return null;
Dictionary<Node, Node> hashMap = new Dictionary<Node, Node>();
Node dfs(Node curr)
{
if (hashMap.ContainsKey(curr))
return hashMap[curr];
Node clone = new Node(curr.val);
hashMap[curr] = clone;
foreach (Node neighbor in curr.neighbors)
{
clone.neighbors.Add(dfs(neighbor));
}
return clone;
}
return dfs(node);
}
}
Also here's an screenshop:

Note: I tried copying the solution but did not work anyway.
Metadata
Metadata
Assignees
Labels
No labels