This commit is contained in:
Hardik Pawar 2024-10-03 11:45:03 +05:30
parent d2b3c1d11a
commit fb13521086

View File

@ -47,6 +47,8 @@ def get_middle(head: Node | None) -> Node | None:
slow: Node | None = head
fast: Node | None = head
while fast is not None and fast.next is not None:
if slow is None: # This should never happen, but it satisfies the type checker
return None
slow = slow.next
fast = fast.next.next