Exercise 1 solution class Node: def __init__(self, value, next=None): self.value = value self.next = next def build(values): head = None for v in reversed(values): head = Node(v, head) return head def middle(head): slow = fast = head while fast and fast.next: slow = slow.next fast = fast.next.next return slow.value if slow else None print(middle(build([1, 2, 3, 4, 5])), middle(build([1, 2, 3, 4])), middle(build([7])), middle(None)) Output: 3 3 7 None The fast pointer moves two nodes for every one the slow pointer moves, so when fast reaches the end, slow is halfway. One pass, no length needed. For an even number of nodes this returns the second of the two middle nodes (3 in 1-2-3-4). The "while fast and fast.next" test covers the empty list, a single node, and both parities without special cases.