A JPMorganChase payment workflow stores ordered processing steps in a singly linked list. Given the heads of two singly linked lists and integers i and j, replace every node in the first list from index i through index j, inclusive, with the entire second list. Return the head of the updated list.
The input lists are represented by ListNode objects with integer val and next fields. The replacement must reuse the existing nodes rather than copying values into a new array.
Implement splice_lists(head1, head2, i, j).
head1: head of a non-empty singly linked listhead2: head of a non-empty singly linked listi, j: integers satisfying 0 <= i <= j < length(head1)def splice_lists(head1, head2, i, j):