1.值得背的题
/*** Definition for singly-linked list.* struct ListNode {* int val;* struct ListNode *next;* };*/
struct ListNode *detectCycle(struct ListNode *head) {struct ListNode*fast=head;struct ListNode*slow=head;while(fast!=NULL&&fast->next!=NULL){slow=slow->next;fast=fast->next->next;if(slow==fast){struct ListNode*good=fast;struct ListNode*bad=head;while(good!=bad){good=good->next;bad=bad->next;}return bad;}}return NULL;
}