Clone a Graph

Talk it through with a coach who asks guiding questions and gives hints until you reach the answer. Pass to mark the challenge as completed.

The problem

  • medium
  • Pro

Given one node of a connected undirected graph, where each node has a value and a list of neighbours, build a deep copy of the whole graph. Explain how you avoid copying a node twice or looping forever.

Talk this problem through with an AI coach

This is a Pro challenge. Sign in with Google, then upgrade to start a voice session.

Start free →