Skip to content

Commit beb0e1c

Browse files
authored
Create 1669-merge-in-between-linked-lists.py
1 parent 18f3716 commit beb0e1c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Diff for: python/1669-merge-in-between-linked-lists.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution:
2+
def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode:
3+
curr = list1
4+
i = 0
5+
while i < a - 1:
6+
curr = curr.next
7+
i += 1
8+
9+
head = curr
10+
while i <= b:
11+
curr = curr.next
12+
i += 1
13+
head.next = list2
14+
15+
while list2.next:
16+
list2 = list2.next
17+
list2.next = curr
18+
return list1

0 commit comments

Comments
 (0)