Skip to main content

Linked List

Floyd's fast and slow pointer

ListNode* slow = head;
ListNode* fast = head;
while (fast != nullptr && fast->next != nullptr) {
// do something here
slow = slow->next;
fast = fast->next->next;
}