Linked List Copy

Given the head of a singly linked list, return a new list with the same values.

1def copy_list(head: Optional[ListNode]) -> Optional[ListNode]:
2 dummy = ListNode(0)
3 tail = dummy
4 cur = head
5 while cur:
6 tail.next = ListNode(cur.val)
7 tail = tail.next
8 cur = cur.next
9 return dummy.next
cur
1
0
3
1
5
2
copied=[]
Step 1 / 3
Step 1:
Initialize dummy and tail to build the copy.
Pointers: cur=0
Focus: select @ [0]