#86
Partition List
specialist · 710 · lc medium +30 · verified · 60.7% accepted · 8,012 likes · top 60%
Description
Partition linked list head so that all nodes with values strictly less than x come before all nodes with values at least x. The original relative order within each partition must be maintained.
Example 1:
Input: head = [1,4,3,2,5,2], x = 3
Output: [1,2,2,4,3,5]
Example 2:
Input: head = [2,1], x = 2
Output: [1,2]
Code
1
2
3
4
5
6
7
8