Even after odd problem


its not passing one test case . please help

hello @gulatigarvita08
run ur code for this test case
7
2 2 4 4 6 6 8

1 Like

ya its not working . but am not able to find its reason

its working for all odds but not for all evens.

see dont make it complicated .
first read list in main function.
now call even function -> this function should iterate the given list from start and extarct all even nodes , add them in list and return head of the list.

similary call odd function and extract all odds from the given list,add them into new list and return its head.
if odd list is null then print even list
otherwise add even list to the tail of odd list and then print print head of odd.

1 Like

can you please send me its code.

refer this-> https://ide.codingblocks.com/s/256198
first reading list.
then
calling even and odd function . they will prepare an even and odd list respectively and send their head nodes.
now if head of odd list is not null then merging the tail of odd lsit with head of even list.
then printing the new list formed.

1 Like

okay thank you so much