i thought of breaking it into two lists merge them and sorting them
in this way
but i dont have this breaking into two stuff here??Code:node* merge(node* l1,node* l2)
{
if ((!l1)&&(!l2))
{
return NULL;
}
if (!l1)
{
v1=99999999999;
v2=l2->val;
}
if (!l2)
{
v2=99999999999;
v1=l1->val;
}
if (v1>v2)
{
l2->next=merge(l1,l2->next);
return l2;
}
else
{
l1->next=merge(l1->next,l2);
return l1;
}
}
because i need to sort a single linked list
??