here is my code https://ide.codingblocks.com/s/374512 with auxillary space
Even after odd how to do this inplace
Your code is working fine, what issue are you getting in this?
i want to do inplace
https://practice.geeksforgeeks.org/problems/rearrange-a-linked-list/1 in this question we have do it O(1) SPACE
Okay I got it, you want to do it in fixed space constraints.
Follow up this code, as it’s my personalised code for better understanding. You would also like it
i think we cannot do like that
Why do you think so?
or can we do it as it is
See what you did is also right, it’s just the code I have shared with you will do it with only 4 pointers that’s a constant space.
basically u r making all odd position a linked list and even position linkedlist and combining them together in O(N) ->TC AND O(1)->SC
yeah , we are using the same old nodes of the list instead of creating new nodes that why it is O(1) space.