Amazon.com Interview Question
1,219 Interview Reviews |
Back to all Amazon.com Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Senior Software Engineer at Amazon.com:
How to detect loops in a linked list without using a data structure
See more for this Amazon.com Senior Software Engineer Interview
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (4)
You could check for every position i you come by as you jump from node to node, if any of the previous i-2 nodes' next pointer points to you. If there is a cycle, one will point to you.
Helpful Answer?
Yes |
No
Inappropriate?
suppose there is 'value' field in each node of linked list other that ther 'next node pointer'
as you traverse the list .. make the value field -1 or something like MAX_INT.... keep doing it either list ends or you see MAX_INT again...
Helpful Answer?
Yes |
No
Inappropriate?
Helpful Answer?
Yes |
No
Inappropriate?
Members can
answer or comment on this question
–
Join Now (It's Free) or
Sign In



4 of 5 people found this helpful
by jeremy: