private void CopyNodes(ComplexListNode node) { var head = node; while (node != null) { var cpNode = new ComplexListNode(node.val); cpNode.next = node.next; node.next = cpNode; node = cpNode.next; } }
private ComplexListNode CloneNodes(ComplexListNode node) { CopyNodes(node); ConnectSibilingNodes(node); return(SliceNodes(node)); }