Doubt doubt doubt

https://ide.codingblocks.com/s/587303 --> Problem??

Me hamesha ek-do test cases me atak jaata hu.

Hi so basically order of elements should remain the sameā€¦
consider this input
7
1 2 4 3 8 5 6

ur o/p
1 3 5 2 8 4 6

expected o/p
1 3 5 2 4 8 6

in ur o/p 8 is coming before 4 while in input its vice versa

u can refer to this solution

I had solved the same question on gfg https://practice.geeksforgeeks.org/problems/segregate-even-and-odd-nodes-in-a-linked-list5035/1

https://ide.codingblocks.com/s/587584---> Problem???

the link u just shared there is no code saved over this linkā€¦

try doing it using 4 pointers as i shared in my solutionā€¦ head and tail for even list and head and tail for odd listā€¦ then merge them in end.

i am also using 4 pointersā€¦code is not working.

pls add comments about what u are doing in ur codeā€¦

yrr ek bat btao tum phle evenhead and oddhead ko initialize krre ho fir vapis head ke starting se start krre hoā€¦ isse acha sidha 4 pointers se start kro na jaise maine explain kiya hai apne code meiā€¦ jab tum koi logc sochte ho to use paper pe dry run krke bhi dekha kro ki approach shi hai ki ni

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.