Unofficial C Solution to Problem 2.3 in Cracking the Coding Interview (5th Edition)

21 Apr

The description of this question is not quite clear. What does “given only access to that node” exactly mean? If we cannot read any other node, it is impossible to finish the work. If we could only read the node, we should remember to free the deleted node somewhere else to avoid the memory leak. In my solution, I return the pointer to the really-deleted node inside the function, and free it outside.

Leave a Reply

Your email address will not be published. Required fields are marked *