Detect cycles in a single linked list