You are given two linked lists, list1 and list2, of sizes n and m. Remove the nodes of list1 from the a-th node to the b-th node (0-indexed), and put list2 in their place. Return the head of the resulting list.
You are given two linked lists, list1 and list2, of sizes n and m. Remove the nodes of list1 from the a-th node to the b-th node (0-indexed), and put list2 in their place. Return the head of the resulting list.
Nodes 3 to 4 of list1 must be cut out and list2 put in their place. To do that we need the node just before the cut (#2) and the node just after it (#5). prev starts on the head.
▼ prev: node a-1▼ after: node b+1▲ tail: end of list2■ cut a..b