I have to delete all the occurences of the given key from linked list


i am not getting correct output
please help

hello @Vipul.kapoor
wait i m checking

image
why this return statement?
remove it

removed but it is still not working

what test case u r giving

it is failing for all the test cases
only the element at the head is printed

image
here it should be
tail->next=n;

for input 12422 -1 2
output is coming 1422

u are deleting ur temp whenever its data matched with key.
so this statement
image
will become invalid. because temp is already deleted.

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.