Iterative Solution | Python
Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Code\n\n# Definition for singly-linked list.\n# class ListNode:\n#     def __init__(self, v
# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\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        tempA = tempB = list1\n\n        while a>1:\n            tempA=tempA.next\n            a-=1\n        \n        while b>=0:\n            tempB = tempB.next\n            b-=1\n\n        tempA.next = list2\n        \n        while tempA and tempA.next:\n            tempA=tempA.next\n\n        tempA.next = tempB\n\n        return list1\n\n\n        \n```
['Linked List', 'Python', 'Python3']