public static Node test6(Node node) {
Node head = node;
Node fast = node;
Node slow = node;
while (fast.next!=null && fast!=null) {
fast = fast.next.next;
slow = slow.next;
if (fast.value == slow.value) {
break;
}
}
fast = head;
while (fast.next!=null && fast!=null) {
fast = fast.next;
slow = slow.next;
if (fast.value == slow.value) {
break;
}
}
return fast;
}
网友评论