题目简介
LeetCode
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
typedef struct ListNode Node;
struct ListNode* middleNode(struct ListNode* head){
Node* fast = head;
Node* slow = head;
if(head->next == NULL)
{
return head;
}
while(fast != NULL)
{
if(fast->next == NULL)
{
break;
}
fast = fast->next->next;
slow = slow->next;
}
return slow;
}