> For the complete documentation index, see [llms.txt](https://r24zeng.gitbook.io/leetcode-notebook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://r24zeng.gitbook.io/leetcode-notebook/wan-quan-an-zhao-jiu-zhang-suan-fa-shua-de-60-dao-zuo-you/vi.-linked-list/86.-partition-list.md).

# 86. Partition List

Too easy!

{% hint style="success" %}

### Define two dummy notes and heads.&#x20;

### 定义两个虚拟节点和两个头。

{% endhint %}

{% tabs %}
{% tab title="Java" %}

```java
class Solution {
    public ListNode partition(ListNode head, int x) {
        ListNode dump1 = new ListNode(), dump2 = new ListNode();
        ListNode pre1 = dump1, pre2 = dump2;
        while(head != null) {
            if(head.val < x) {
                pre1.next = head;
                pre1 = pre1.next;
            } else {
                pre2.next = head;
                pre2 = pre2.next;
            }
            head = head.next;
        }
        pre2.next = null;
        pre1.next = dump2.next;
        return dump1.next;
    }
}
```

{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}
