In the code below, when using two pointers technique, it's confusing that why we use slow.next and fast.next.next. For example in the linked list [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], if we are in the last position '10' (fast pointer), the slow pointer should be in the '8' position. Could someone please clarify that?
def middleNode(self, head):
slow = fast = head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
return slow