- Use two
- Go through the list with a pointer
tmp.val >= x, append the current node to
- And remember to let
tmp.next = null.
- Finally, connect
head of a linked list and a value
x, partition it such that all nodes less than
x come before nodes
greater than or equal to
preserve the original relative order of the nodes in each of the two partitions.
Input: head = [1,4,3,2,5,2], x = 3