getting run error in test case 0 please help me to identify the mistake in my code.
Insert and functions are written correct.
please check this function
node *rearrangeEvenOdd(node *head)
{
node *a=NULL;
node *ptr=head;
while(ptr!=NULL)
{
if((ptr->data)%2==0)
insertattail(a,ptr->data);
else
insertathead(a,ptr->data);
ptr=ptr->next;
}
ptr=a;
while(ptr->next->data%2==1)
ptr=ptr->next;
node *b=ptr->next;
ptr->next=NULL;
reverse(a);
ptr=a;
while(ptr->next!=NULL)
ptr=ptr->next;
ptr->next=b;
return a;
}
Run error in test case 0
please provide the ide link of your complete code as it will be easy to check and also explain a little bit about your approach
sir i traversed over the LL. if the num is even i inserted it at tail if it was odd i inserted it at head. but due to this approach we get odd numbers in reverse order. so i reversed the odd numbers.
sir again the same problem 1m ✓ in the loop i added &&ptr->next!=NULL just now ✓ but still i am getting run error