Merge in Between Linked Lists (LeetCode-style linked-list coding question)
Asked in the Round 1 (online HackerRank assessment) stage.
Given the heads of two singly linked lists, integers a and b, remove nodes at positions a through b from list1, then insert all nodes from list2 in their place. Return the head of the modified linked list.
The function receives ListNode objects. In the examples and tests, linked lists are represented as arrays for serialization.
merge_in_between(list1, a, b, list2)
def merge_in_between(list1, a, b, list2):