What is the need of ahead pointer here

we can solve it without ahead pointer also i.e using 2 pointers.

how?

to reverse this using recursion we don’t need any extra pointer.
in iteration we need the prev node, curr node and the next node.

we need the next node becoz
after pointing the curr node towards the prev node
we don’t have next node.

so this is why we need the next pointer which holds the next node.

hope this will help u
if i am able to resolve ur doubt
then pls mark ur doubt as resolved and rate my work.

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.