You are given two singly linked lists list1 and list2, along with two integers a and b. Modify list1 in place by removing the contiguous segment of nodes from index a through index b inclusive, using list2 into list1 at the position where that segment was removed.
Return the head of the updated linked list.
The method signature is ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2).
Constraints:
list1.length
a b list1.length
list2.length
You are given two singly linked lists list1 and list2, along with two integers a and b. Modify list1 in place by removing the contiguous segment of nodes from index a through index b inclusive, using list2 into list1 at the position where that segment was removed.
Return the head of the updated linked list.
The method signature is ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2).
Constraints:
list1.length
a b list1.length
list2.length