• + 0 comments

    This is so much better than the code given in editorial.

    This solution does not need extra space to store the Node. (Although it does have a temp Node pointer, but node pointer is fine, storing the object Node would be big space consuming and interviewer will definitely ask to improve upon the solution given in the editorial)

    Btw, you can also avoid to have that extra temp node pointer in the else condition.