
印象题
/**
* Definition for singly-linked list.
* class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
* val = x;
* next = null;
* }
* }
*/
public class Solution {
public ListNode detectCycle(ListNode head) {
ListNode fast=head,slow=head;
while(true){
if(fast==null||fast.next==null) return null;
fast=fast.next.next;
slow=slow.next;
if(fast==slow)break;
}
fast=head;
while(slow!=fast){
slow=slow.next;
fast=fast.next;
}
return fast;
}
}



















![[大语言模型-论文精读] MoRAG - 基于多部分融合的检索增强型人体动作生成](https://i-blog.csdnimg.cn/direct/6cb68d3693734e1a8267887bd1e57f22.png)