Linked list: Split the list

ListNode* prev = NULL;
ListNode* firstHalf = head;
ListNode* secondHalf = head;
while (secondHalf || secondHalf->next) {
    prev = firstHalf;
    firstHalf = firstHalf->next;
    secondHalf = secondHalf->next->next;
}
//The head of the scend half one
ListNode* mid = firstHalf;
prev->next = NULL;

Last updated