Plz correct this code

Hello @devwrath1999 it is mentioned in the question that you have to arrange in this way:
Here we are talking about the node number and not the value in the nodes.
but you are doing in the form of values.

@devwrath1999 see this:


i have corrected your code and made one change that instead of checking if(val%2):
i have done like this :
if(i%2): i is the value of the for loop.
Happy Learning!!