This commit is contained in:
Hardik Pawar 2024-10-03 11:56:04 +05:30
parent 1ac1f0c0e4
commit ed62d33870

View File

@ -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