TheAlgorithms-C/leetcode/src/876.c

20 lines
355 B
C
Raw Normal View History

2019-09-03 23:52:24 +08:00
/**
* 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;
}