Merge In Between Linked Lists LeetCode solution in Python
1class Solution:2def mergeInBetween(3self, list1: ListNode, a: int, b: int, list2: ListNode4) -> ListNode:5head = list16for _ in range(a - 1):7head = head.next8cur = head.next9for _ in range(b - a):10cur = cur.next11head.next = list212while head.next:13head = head.next14if cur.next:15head.next = cur.next16return list1