Sir, what's wrong with my code

hello @chandreshmaurya

please explain ur approach.

sir, maine 3 pointer initialize kiya hai , curr pointer sare LL ke sare element check krega. aur usi ke just piche ‘prev1’ pointer ko rkha hai . ydi koi even number aata hai to simply ‘prev1’ aur ‘curr’ aage chale jayenge. ydi koi odd number aata hai to ‘curr’ element to ‘prev’ pointer point krega aur only ‘prev’ pointer hi aage jayega.

‘prev1’ aur ‘curr’ ye dono pointer age nhi jayenge.

ss

ye else part batana , idhar kya karne ki try kar rahe ho?

a)aur ek aur chiz agar prev1 NULL hua to , prev1->next segmentation fault dega.
b) is approach me tumhara relative order maintain naho ho payega, uski wajah se hamesha wrong answr aayega tumhara kyunki output me relative ordering same honi chaiye

sir, ydi koi odd number milta hai to, uss ‘curr’ elment ko ‘prev’ wala pointer point krega. ‘curr’ element ko remove krenge.

‘prev1’ , ‘curr->next’ ko point krene lgega.

tumhara prev aur prev1 dono starting me NULL rahenge .

ab kyunki ye NULL hai tum iska next nahi access kar sakte kyuki segmenation fault dega.

ek baar ispe try kar ke dekho error samjh aa jayega->
3
1 2 3

prev1 me last even store kar rahe ho right?
but prev me kya store kar rahe ho?

sir, segmentation fault de rha hai . yes sir, ‘prev1’ me even store kr rha hu aur ‘prev’ me odd.

…

ha kyunki tum null access kar rahe ho.

to is case ko handel karo tum direcly prev ya prev1 ke next ko access nahi kar sakte , jo bhi tumhara logic hai uske hisab se is case ko handel karo.

sir, i need some approach.

Sir, i tried it in different way. But, i’m not getting ‘segmentation fault’. please remove my error. my code-> https://ide.codingblocks.com/s/465553

this is the updated llink ->

ignore my last response

Sir, now it’s clear. but, i’m getting one TLE in one test case.

…

check my last response, shared the updated link

yes sir, i got it. thank you.

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.