I can’t understand why 2 test cases are giving wrong answer.
Even-After-Odd (Linked Lists)
@taritkandpal hey apka woh wala case reh rha hai jab even ll me koi element na ho ya even head NULL ho to handlekro case ko ||ly when odd head null ho tab handle kro case ko.
The cases where there are only even elements or there are only odd elements are already considered. This test case is working.
Head to null sisf tab reh sakta hai if n is 0 jisme to output ayega hi nhi.
@taritkandpal nahi agr odd 0 ho to apko even head dalna hai output me and even ki last node ka next NULL krna hoga jo apne nhi kia ,also agr even na ho odd ke last me NULL bhi dalna hai and head jo hai odd ki first node hogi .
Bro mene odd even ki different lists nahi banai hain so i am not able to understand what you are trying to say.
But could you simply correct the code or tell me the test cases which are failing.
@taritkandpal bro mein bhi wahi keh rha hoon ,agr apne alag list bnayi hai to apko dono ko connect krna hai ,mtl odd tail ke age even ka head and even ke tail ke next me NULL ,to suppose apki odd wali ll khali hai to head jo hoga woh even head hoga and if even ll is empty than apko odd tail ke next me NULL dalna hai ,ye cases handle kro app ,yhi do test cases tabhi atk rhe hai.
bro those test cases are not failing… jo code mene upar post kia use run karo…
agar odd list khali bhi ho to bhi sahi output aa rha and same goes for even
@taritkandpal you didn’t have checked first element while taking input odd hi assume krlia apne,agr even ho to woh bhi last me jayega.
first element koi bhi ho… wo to direct insert ho rha…
uske baad jo even aaye wo uske aage insert honge… and jo odd wo uske pehle
@taritkandpal hai order maintain rehna chyy suppose tera pehla element odd hai to tune odd ke age baki ke odd elements lgaye hai jabki woh odd ke piche lgne chyy ,isse odd walo ka sequence maintain nhi horha ,jabki even ka hofrha hai ,this is the problem jo mein btana chah rha hoon apko.