class Solution {
public ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) {
ListNode breakPointFront = list1, breakPointRear = list1;
for (int i = 0; i < a - 1; ++i) {
breakPointFront = breakPointFront.next;
}
breakPointRear = breakPointFront;
b = b - a + 2;
for (int i = 0; i < b; ++i) {
breakPointRear = breakPointRear.next;
}
breakPointFront.next = list2;
while (list2.next != null) {
list2 = list2.next;
}
list2.next = breakPointRear;
return list1;
}
}