Nth node from the end

problem:

my sol is giving run time error


please help

your approach is not correct

Modified Code

can you please explain why my approach is wrong

when you move temp x move forward
after that you have to move both pointer forward

consider this example
10
1 2 3 4 5 6 7 8 9 10
delete 3rd node from last

why aren’t we deleting that node.
won’t it lead to memory leak

yes , we should have to delete that node as well
you can very easily delete that node using a temp variable

1 Like

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.