mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
20 lines
353 B
C
20 lines
353 B
C
/**
|
|
* Definition for singly-linked list.
|
|
* struct ListNode {
|
|
* int val;
|
|
* struct ListNode *next;
|
|
* };
|
|
*/
|
|
|
|
struct ListNode *middleNode(struct ListNode *head)
|
|
{
|
|
struct ListNode *fast, *slow;
|
|
fast = slow = head;
|
|
while (fast && fast->next)
|
|
{
|
|
slow = slow->next;
|
|
fast = fast->next->next;
|
|
}
|
|
return slow;
|
|
}
|