Merge In Between Linked Lists LeetCode solution in Python

1
class Solution:
2
def mergeInBetween(
3
self, list1: ListNode, a: int, b: int, list2: ListNode
4
) -> ListNode:
5
head = list1
6
for _ in range(a - 1):
7
head = head.next
8
cur = head.next
9
for _ in range(b - a):
10
cur = cur.next
11
head.next = list2
12
while head.next:
13
head = head.next
14
if cur.next:
15
head.next = cur.next
16
return list1

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0