Middle of the Linked List:题目链接 AC code: 123456789101112 struct ListNode* (struct ListNode* head){ if (head == NULL || head->next == NULL) { return head; } struct ListNode* fast = head, * slow = head; while (fast!=NULL && fast->next != NULL) { slow = slow->next; fast = fast->next->next; } return slow;} 如果是返回第一个中间节点呢? 赞微海报分享
近期评论