Interview Question

Senior Software Engineer Interview Carlsbad, CA

How can you tell if a linked list is circular (goes on

  forever because it connects to a previous node)?

Interview Answer

1 Answer


Have two cursors, one moving one node at a time and the other moving two at a time. If the two nodes ever equal each other, it's a circular linked list.

Interview Candidate on Sep 4, 2013

Add Answers or Comments

To comment on this question, Sign In with Facebook or Sign Up