作者新建立的社区:https://bbs.csdn.net/forums/FKBZM?typeId=22226💖💛💙
期待hxd的支持哈🎉 🎉 🎉
思路:直接快慢指针,慢指针走一步,快指针走两步(注意基偶)。
struct ListNode* middleNode(struct ListNode* head){
struct ListNode* slow=head;
struct ListNode* fast=head;
if(head->next==NULL)
return head;
while(fast!=NULL && fast->next!=NULL)
{
slow=slow->next;
fast=fast->next->next;
}
return slow;
}