We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1ac1f0c commit ed62d33Copy full SHA for ed62d33
data_structures/linked_list/merge_sort_linked_list.py
@@ -35,10 +35,12 @@ def get_middle(head: Node | None) -> Node | None:
35
if head is None or head.next is None:
36
return None
37
38
- slow: Node = head
+ slow: Node | None = head
39
fast: Node | None = head.next
40
41
while fast is not None and fast.next is not None:
42
+ if slow is None:
43
+ return None
44
slow = slow.next
45
fast = fast.next.next
46
0 commit comments