PythiloLesson 13 of 32 · progress kept in this browser

Find the middle with slow and fast pointers

You do not need the length of a linked list to find its middle. Move one pointer one step and another two steps at a time. When the fast one reaches the end, the slow one is halfway.

# 1 -> 2 -> 3 -> 4 -> 5
# slow: 1, 2, 3   fast: 1, 3, 5
Your task

Node(value, next) is provided. Write middle(head) returning the middle node in one pass; for an even length return the second middle. Return None for an empty list.