Code is not giving any output

Hello @Mudit809,

Your code is facing TLE i.e. Time Limit Exceeded.
Reason:
infinite execution of the loop:
while(curr!=end){}
Reason:
else curr= curr->next;
Above will execute only for odd numbers in the linked list.
Once, it will encounter an even number. It will be stuck to that node as there is no code for moving ahead in the linked list there.

Correct it.

can u please give the correct code for this problem.

Sure @Mudit809,

You may refer to the following code:

bhaiya this is perfectly fine but it is taking O(n) stack space. Can you help me with the code by which the required arrangement will be done in O(1) stack space / inplace.

Hello @Mudit809,

I just wrote the following code with space complexity of O(n):

Hope, this would help.

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.