linear_list/linked_list/sort.cpp
ListNode* split(ListNode* head, int size)
{
    for (int i = 1; i < size && head != nullptr; i++)
    {
        head = head->next;
    }

    if (head == nullptr)
    {
        return nullptr;
    }

    ListNode* second = head->next;
    head->next = nullptr;

    return second;
}
/**
 * Divide the linked list into two lists.
 * The first list contains first n nodes.
 * Return the head of the second list.
 */
Divide the linked list into two lists.
The first list contains first n nodes.
Return the head of the second list.
Divide the linked list into two lists . The first list contains first n nodes . Return the head of the second list .
ListNode* split(ListNode* head, int size)
{
    for (int i = 1; i < size && head != nullptr; i++)
    {
        head = head->next;
    }
    if (head == nullptr)
    {
        return nullptr;
    }
    ListNode* second = head->next;
    head->next = nullptr;
    return second;
}
ListNode * split ( ListNode * head , int size ) { for ( int i = 1 ; i < size && head != nullptr ; i ++ ) { head = head -> next ; } if ( head == nullptr ) { return nullptr ; } ListNode * second = head -> next ; head -> next = nullptr ; return second ; }
Divide the linked list into two lists.
Divide the linked list into two lists .