Test case 0 coming wrong

Please check https://ide.codingblocks.com/s/422695

Hello @zabhishek please wait checking your code:

Hello @zabhishek so the error is that your code is not able to maintain the relative order of the numbers in which they have arrived.
like for this test case:
6
2 4 1 3 6 8
output should be: 1 3 2 4 6 8

Oh i get it. How should i proceed to resolve this?

@zabhishek i am not sure whether with your approach the relative order could be maintained or not.
you can simply do this by two new nodes and adding odd and even separately and then joining them.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.