Python | Easy
see the Successfully Accepted Submission\n\n# Code\n\n# Definition for singly-linked list.\n# class ListNode:\n#     def __init__(self, val=0, next=None):\n#   
[see the Successfully Accepted Submission](https://leetcode.com/problems/merge-in-between-linked-lists/submissions/1208722799/?envType=daily-question&envId=2024-03-20)\n\n# Code\n```\n# Definition for singly-linked list.\n# class ListNode:\n#     def __init__(self, val=0, next=None):\n#         self.val = val\n#         self.next = next\nclass Solution:\n    def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode:\n        # Find the ath node\n        current = list1\n        for _ in range(a - 1):\n            current = current.next\n        \n        # Find the bth node\n        temp = current\n        for _ in range(b - a + 2):\n            temp = temp.next\n        \n        # Connect ath node to the head of list2\n        current.next = list2\n        \n        # Find the end of list2\n        while list2.next:\n            list2 = list2.next\n        \n        # Connect the end of list2 to the b+1th node\n        list2.next = temp\n        \n        return list1\n```\n![image](https://assets.leetcode.com/users/images/b1e4af48-4da1-486c-bc97-b11ae02febd0_1696186577.992237.jpeg)
['Python3']