Skip to content

Commit d2b3c1d

Browse files
committed
Fix
1 parent 62d2412 commit d2b3c1d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

data_structures/linked_list/merge_sort_linked_list.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ def get_middle(head: Node | None) -> Node | None:
4444
if head is None or head.next is None:
4545
return head
4646

47-
slow: Node | None = head # one node at a time
48-
fast = head # two nodes at a time
49-
while fast.next and fast.next.next:
47+
slow: Node | None = head
48+
fast: Node | None = head
49+
while fast is not None and fast.next is not None:
5050
slow = slow.next
5151
fast = fast.next.next
52+
5253
return slow
5354

5455

0 commit comments

Comments
 (0)