> For the complete documentation index, see [llms.txt](https://longxingtan.gitbook.io/mle-interview/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://longxingtan.gitbook.io/mle-interview/01_leetcode/02_linked_list/876.-middle-of-the-linked-list.md).

# 876. Middle of the Linked List

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

## solution

```python
class Solution:
    def middleNode(self, head: Optional[ListNode]) -> Optional[ListNode]:
        slow = fast = head
        while fast and fast.next:
            slow = slow.next
            fast = fast.next.next
        return slow
```

时间复杂度：O(n)\
空间复杂度：O(1)
