From ed62d338705e2add7b5c3eb5ae0566745246009e Mon Sep 17 00:00:00 2001 From: Hardik Pawar Date: Thu, 3 Oct 2024 11:56:04 +0530 Subject: [PATCH] Fix --- data_structures/linked_list/merge_sort_linked_list.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/data_structures/linked_list/merge_sort_linked_list.py b/data_structures/linked_list/merge_sort_linked_list.py index deaab02d4..68727685e 100644 --- a/data_structures/linked_list/merge_sort_linked_list.py +++ b/data_structures/linked_list/merge_sort_linked_list.py @@ -35,10 +35,12 @@ def get_middle(head: Node | None) -> Node | None: if head is None or head.next is None: return None - slow: Node = head + slow: Node | None = head fast: Node | None = head.next while fast is not None and fast.next is not None: + if slow is None: + return None slow = slow.next fast = fast.next.next