Can you please share the solution of the ques

Can you please share the solution of the ques

Hey @haseebshaik00

// Following is the node structure

/**************

class node{

public:

    int data;

    node * next;

    node(int data){

        this->data=data;

        this->next=NULL;

    }

};

***************/

node* arrange_LinkedList(node* head)

{

   node *oh=NULL,*ot=NULL,*eh=NULL,*et=NULL;

    node * current=head;

    while(current!=NULL)

    {

        if((current->data)%2!=0)

        {

            if(oh==NULL)

            {

                oh=current;

                ot=current;

            }

            else{

                ot->next=current;

                ot=ot->next;

            }

            current=current->next;   

        }

        else

        {

            

            if(eh==NULL)

            {

                eh=current;

                et=current;

            }

            else{

                et->next=current;

                et=et->next;

            }

            current=current->next; 

            

        }

        

     }

     if(eh==NULL || oh==NULL)

        return head;

    if(et!=NULL)

    et->next=NULL;

    if(ot!=NULL)

        ot->next=NULL;

    if(eh!=NULL && ot!=NULL)

    {

        ot->next=eh;

        

    }

  head=oh;

    return head;

} 

If this resolves your query then please mark it as resolved :slight_smile: