Skip to content

Commit ed62d33

Browse files
committed
Fix
1 parent 1ac1f0c commit ed62d33

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

data_structures/linked_list/merge_sort_linked_list.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ def get_middle(head: Node | None) -> Node | None:
3535
if head is None or head.next is None:
3636
return None
3737

38-
slow: Node = head
38+
slow: Node | None = head
3939
fast: Node | None = head.next
4040

4141
while fast is not None and fast.next is not None:
42+
if slow is None:
43+
return None
4244
slow = slow.next
4345
fast = fast.next.next
4446

0 commit comments

Comments
 (0)