// at least two nodes if(!head || !head->next) return head; // find the middle node ListNode *slow = head; ListNode *fast = head; while(fast->next && fast->next->next) { slow = slow->next; fast = fast->next->next; }
// at least two nodes if(!head || !head->next) return head; // find the middle node ListNode *slow = head; ListNode *fast = head->next->next; while(fast && fast->next) { slow = slow->next; fast = fast->next->next; }