Skip to content

slow / fast [terminology]

Terminology

Usage

  • Use for pointers moving at different speeds.
  • They strongly signal Floyd's cycle detection or linked-list midpoint discovery.
# Find the middle.
slow = head
fast = head
while fast and fast.next:
    slow = slow.next
    fast = fast.next.next
# For odd length, skip the middle node.
if fast:
    slow = slow.next

See 234. Palindrome Linked List.