Please see getting runtime error


#1

ListNode* Solution::partition(ListNode* A, int B) {
if(!A or !A->next)
return A;
ListNode *second=NULL,*head2=NULL,*curr=A;
while(curr->next!=NULL)
{
while(curr->next->val>=B)
{
if(!second)
{
second=curr->next;
second=head2=second;
}
else
{
second->next=curr->next;
second=second->next;
}
curr->next=curr->next->next;

    }
    curr=curr->next;
}
second->next=NULL;
curr->next=head2;

return A;

}