Given a linked list containing integers as values, write an algorithm that detects if there is a loop or cycle in the list.
Anonymous
Another way is to look at the pointer references. Basically, if you store a temporary list of visited nodes you'll have references to each one. Now the value they store may not be unique, but the memory address will be (it should be a new object). So if you encounter a duplicate reference/memory location you've got a loop since you've got two references to the same node (the original node and the looping pointer to it).
Check out your Company Bowl for anonymous work chats.