Unable to clr all testcases

if u want to do using stl then make 2 lists… one for odd and other for even… then print ans accordingly…

I have cleared 2 testcases using this approach, i am unable to understand why other 2 are not cleared

are bhai khud dry run krke dekho order aage piche hoga aise… 2 list use kro… agr hm linked list implement bhi krte hai to even and odd dono ke liye alg head pointers maintain krte hai and in end join krte hai…
5
1 2 4 7 6
ye input pe dekhlo ur code is failing… 2 min lgenge paper pe dry run krne ke liye…
and ye jruri thodi hai ki partial test case chlge to tumhare code ka logic shi hai…

For input, 5- 1 2 4 7 6 the output is 7 1 2 4 6 which i believe is correct, all evens are after odds, should the output be 1 7 2 4 6?

ok… just a min… i understood the ques the vice versa… i thought odd after even… let me see ur code

consider this input…
5
1 2 3 4 5

ur o/p 5 3 1 2 4
expected o/p 1 3 5 2 4

ur soln is basically changing the order of odd elements… just bcoz u are pushing in front whenever u encounter new odd element… are u getting my point

yes, got it, let me try another approach

yes… just use 2 list… one for storing odd elements and other for even elements

done, thanks for ur 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.