I\'m trying to find this algorithm on C++ in .NET but can\'t, I found this one:
// Best solution
function boolean hasLoop(Node startNode){
Node slowNode = Node
This algorithm will find a cycle in a linked list.
one fast node can be used instead:
function boolean hasLoop(Node startNode){
Node slowNode = Node fastNode = startNode;
while (slowNode && fastNode = fastNode.next() && fastNode = fastNode.next()){
if (slowNode == fastNode) return true;
slowNode = slowNode.next();
}
return false;
}