classSolution{publicListNodemergeInBetween(ListNode list1,int a,int b,ListNode list2){ListNode breakPointFront = list1, breakPointRear = list1;// Find the first break pointfor(int i =0; i < a -1;++i){
breakPointFront = breakPointFront.next;}
breakPointRear = breakPointFront;// Cal. the steps to the rear break point
b = b - a +2;// Find the second break pointfor(int i =0; i < b;++i){
breakPointRear = breakPointRear.next;}// Connect
breakPointFront.next = list2;// Until the rear node of the list2while(list2.next !=null){
list2 = list2.next;}// Connect the rear part
list2.next = breakPointRear;return list1;}}