GoalScope — copy_list_with_random_pointer (Qwen2.5-Coder-32B-Instruct) — hover a token to see the patched verbalization
<code>↵ def copy_list_with_random_pointer(head):↵ """Deep copy a linked list with random pointers."""↵ if not head:↵ return None↵ ↵ # Step 1: Create new nodes and insert them next to the original ones.↵ current = head while current:↵ new_node = Node(current.val, current.next, None)↵ current.next = new_node current = new_node.next↵ ↵ # Step 2: Assign random pointers for the new nodes.↵ current = head while current:↵ if current.random:↵ current.next.random = current.random.next current = current.next.next↵ ↵ # Step 3: Restore the original list and extract the copied list.↵ current = head new_head = head.next new_current = new_head while current:↵ current.next = new_current.next current = current.next if new_current.next:↵ new_current.next = new_current.next.next new_current = new_current.next↵ ↵ return new_head</code>