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

3 Answers


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

The key in generic questions like this, is to make sure to cover the fundamentals. There's usually a back-and-forth with the interviewer.

Might be worth doing a mock interview with one of the Microsoft Senior Software Development Engineer experts on Prepfully? Really helps to get some real-world practice and guidance.

Anonymous on 31-May-2020

One or more comments have been removed.
Please see our Community Guidelines or Terms of Service for more information.

Add Answers or Comments

To comment on this, Sign In or Sign Up.