Microsoft Interview Question

Given a linked list with cycle, find the cycle.

Interview Answers

Anonymous

Nov 14, 2010

It's a well known problem. You need to have two pointers one of which traverses the list with a double speed. The cycle is found if sometime after start the fast pointer crosses the slow.

2

Anonymous

Sep 24, 2010

maintain a stack and mark nodes as you go along