SarthakKeshari / CPP-Questions-and-Solutions

This repository aims to solve and create new problems from different spheres of coding. A path to help students to get access to solutions and discuss their doubts.
MIT License
45 stars 132 forks source link

Adding Even after odd LinkedList in GFG folder #424

Closed anshuman725 closed 2 years ago

anshuman725 commented 2 years ago

Issue Id you have worked upon -

413

Briefly explain your program logic -

I have taken 4 nodes two for odd and even head and the other two for odd and even tail so what I am doing is I am checking the node data if it is odd or even, for the case of odd and if the node head pointer is null, I just point the odd node to the odd head and tail and if the odd head is not null then just pointing tail to the next odd node in the list and moving the odd tail forward, similarly I have done for even data in the list and at the end, I just join the two list by pointing the odd tail node to the head of even list and even tail to null.

Screenshots(Attach 2 screenshots of your own input and output) -

image

image


Checklist:

Eg - If your code follow the below guidelines. Kindly change [] to [x]

All the conditions should be fulfilled for considering your code for merging -


anshuman725 commented 2 years ago

@SarthakKeshari Added the question and comments. Please review and tell me if more changes needed.