876. 链表的中间结点

https://leetcode-cn.com/problems/middle-of-the-linked-list/

解法一:快慢指针

class Solution:
    def middleNode(self, head: ListNode) -> ListNode:
        Head = ListNode(None)
        Head.next = head
        slow = fast = Head
        while fast.next and fast.next.next:
            fast = fast.next.next
            slow = slow.next
        return slow.next

最后更新于