Amazon.com
3.3 of 5 3,203 reviews
www.amazon.com Seattle, WA 5000+ Employees

Amazon.com Software Engineer Intern Interview Question

"Write a function which determines if there is a cycle in a linked-list."
Add Tags [?]
Answer Flag Question

Part of a Software Engineer Intern Interview Review - one of 4,603 Amazon.com Interview Reviews

Answers & Comments

0
of 1
vote
Use two pointers. One pointer moves to the next node, the other one moves to the next node's next node in every iteration. If these two nodes match at some point, then you have a cycle. If you reach to the end of the linked-list without a match, then there is no cycle.
- Interview Candidate on Feb 26, 2012 Flag Response

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


Tags are like keywords that help categorize interview questions that have something in common.

Glassdoor is your free inside look at Amazon.com interview questions and advice. All interview reviews posted anonymously by Amazon.com employees and interview candidates.