Why is this code not working?Why is this code not working?

Why is this code not working?Why is this code not working?
Why is this code not working?

For this Question

One Test Case is creating issue that is [1] and n=1.

And Please tell if any other approach available.

hello @cbcao263 what i can see is that your code is passing onyl one test case i have made one change so that your code can pass the given test case mentioned by you and now it is passing 187 test cases out of 208 test cases as a whole .
now if you dry run for the missint test case and add condition like this then you willd definitely be able to submit all the test cases .
https://ide.codingblocks.com/s/338095
if you feel your doubt is cleared please mark this as resolved .
Happy Learning !!

Sir, What was issue in my code that you have solved?
Please tell about that
And Theextra condition too that you told at last.

@cbcao263 i have just added one condition for the test case you specified above in your problem that if the legnth of the linked list and the number to be removed from the last are same then it is simple that you should simpy return null because it is the output the question expects.

if you want to know the better appraoch this code is passing all the test cases with 100% fast sucess rate .


if you feel your doubt is cleared please mark this as resolved .
i hope i have cleared your doubt .
Happy Learning !!

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.