> For the complete documentation index, see [llms.txt](https://jenhsuan.gitbook.io/algorithm/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jenhsuan.gitbook.io/algorithm/notes-of-algorithms/linked-list-split-the-list.md).

# Linked list: Split the list

```
ListNode* prev = NULL;
ListNode* firstHalf = head;
ListNode* secondHalf = head;
while (secondHalf || secondHalf->next) {
    prev = firstHalf;
    firstHalf = firstHalf->next;
    secondHalf = secondHalf->next->next;
}
//The head of the scend half one
ListNode* mid = firstHalf;
prev->next = NULL;
```
