### title

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.

You should preserve the original relative order of the nodes in each of the two partitions.

Example:

Input: head = 1->4->3->2->5->2, x = 3Output: 1->2->2->4->3->5

### Analyze

• 易漏点: 大于等于 x 的链表的末尾的 next 应该指向 null。
/** * Definition for singly-linked list. * function ListNode(val) { *     this.val = val; *     this.next = null; * } *//** * @param {ListNode} head * @param {number} x * @return {ListNode} */var partition = function(head, x) {  const listNode = new ListNode(0)  listNode.next = head
const smallerThanX = new ListNode(0)  const biggerThanX = new ListNode(0)
let cur = listNode.next  let smallPoint = smallerThanX  let bigPoint = biggerThanX  while (cur) {    if (cur.val < x) {      smallPoint.next = cur      smallPoint = smallPoint.next    } else {      bigPoint.next = cur      bigPoint = bigPoint.next    }
cur = cur.next  }
bigPoint.next = null  smallPoint.next = biggerThanX.next
return smallerThanX.next}