Https://hack.codingblocks.com/contests/c/471/315

https://ide.codingblocks.com/s/50088
i think i have solved the question properly but the output value is completely different than what i m inputting …sir have a look on it…thanks in advance

Add the question link

https://hack.codingblocks.com/contests/c/471/315

You have to add all odd elements first than even elements.
eg :you have a linked list 1 4 5 6 3
so all the odd elements (1 5 3) must be placed before all even elements (4 6)
so output should be :1 5 3 4 6

sir that is what i did by placing if and else there but still it does not work…
still not working

Hi Rahul, in line number 18, you have written if(d && 1==0). 1==0 is always false and hence if block will never be executed. Rectify it according to your logic and then share the code.

1 Like

it is only giving right answer for two cases only…
does order of odd no and even no also matter here??

Yes, they should be according to the order of the input like the example given above.
you have a linked list 1 4 5 6 3
so output should be :1 5 3 4 6

ma’am i correceted it but this time it shows run-error for two cases…
i have checked for lots of cases it,s working fine but it is not getting submitted on hackerblock
https://ide.codingblocks.com/s/50088

Run your code for the following:
5
2 2 2 1 1
The output should be: 1 1 2 2 2
Your code gives: 2 1 1 2 2
Also try to think of other corner cases and try to run your code for them as well.

ma’am i fixed it
https://ide.codingblocks.com/s/50467
but i still see run-error for two cases during submisiion…

Hi Rahul, your code is not working fine for the following test cases:
4
1 1 1 2
and
5
1 3 5 7 9
Modify for code for the following test cases.

Hi Rahul, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.