Segmentation fault


Can someone look and tell where i am making mistake

Hi @akshatkaush

I think there is some mistake in your work function. I was not able to understand your approach. It has a very simple approach which i attaching in the link after modifying your code. You will easily be able to understand this.
If you have doubt regarding this simple approach, then please ask.
Link : https://ide.codingblocks.com/s/213370

Hope it Helps.

test case 3 is failing.

Let me check. There might be a corner case.

Hi @akshatkaush

Actually my previous code is also correct. But it jumbles the order of occurrence. Eg if input is 1 2 4 5
My code will give output -> 1 5 4 2. But as it is not explicitly mentioned in the question but the answer is assumed to maintain the order, hence answer should be 1 5 2 4. So, trying a new approach, we can make two sub lists from the original list 1 contains all odd elements and second all even elements in the order given in the question. Then we just join the even sub list at the end of the odd sublist.

Link : https://ide.codingblocks.com/s/213444

hope it helps.