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
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) -
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 -
[x] I have mentioned the question as comment in my solution file.
[x] My code follows the guidelines of this project.
[x] I have performed a self-review of my own code.
[x] I have commented my code.
[x] My code gives the correct output.
[x] I confirm that I have not copied the code from anywhere. In case its found that I have copied even after successful merge then I can be banned from the repository and hacktoberfest.
[x] I affirm that I strictly follow contributing guidelines and code of conduct.
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) -
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 -
[x] I have mentioned the question as comment in my solution file.
[x] My code follows the guidelines of this project.
[x] I have performed a self-review of my own code.
[x] I have commented my code.
[x] My code gives the correct output.
[x] I confirm that I have not copied the code from anywhere. In case its found that I have copied even after successful merge then I can be banned from the repository and hacktoberfest.
[x] I affirm that I strictly follow contributing guidelines and code of conduct.