public class LinkCircleChecker {
public static class Node{
//直观起见,设置为public
public int value;
public Node next;
public Node(int value, Node next) {
this.value = value;
this.next = next;
}
}
public static Boolean checkCircle(Node head){
Node fast = head;
Node slow = head;
while (fast!=null&&fast.next!=null) {
slow= slow.next;
fast=fast.next.next;
if (slow==fast) {
return true;
}
}
return false;
}
}