Microsoft Interview Question: Clone a linked list that has ... |

Interview Question

Senior Software Development Engineer Interview Redmond, WA (US)

Clone a linked list that has a cycle (do not fix the

  cycle). Is there a way to uniquely identify a node without relying on a hash code?

Interview Answer

1 Answer


Use a dictionary. If has entry in dictionary you have found the cycle. So your newly created node will point to a clone of this node and method returns.
A unique way of identifying a node would be to use the address of the C you could use the address returned upon allocation as a unique way of identifying node.

Interview Candidate on 08-Jul-2015

Add Answers or Comments

To comment on this, Sign In or Sign Up.