mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-04-29 17:13:36 +00:00
Fix
This commit is contained in:
parent
4aa953e400
commit
62d2412482
@ -44,10 +44,10 @@ def get_middle(head: Node | None) -> Node | None:
|
|||||||
if head is None or head.next is None:
|
if head is None or head.next is None:
|
||||||
return head
|
return head
|
||||||
|
|
||||||
slow = head # one node at a time
|
slow: Node | None = head # one node at a time
|
||||||
fast = head # two nodes at a time
|
fast = head # two nodes at a time
|
||||||
while fast.next and fast.next.next:
|
while fast.next and fast.next.next:
|
||||||
slow: Node | None = slow.next
|
slow = slow.next
|
||||||
fast = fast.next.next
|
fast = fast.next.next
|
||||||
return slow
|
return slow
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user