Rearrange the list so that all nodes with a value less than x come before nodes with a value greater than or equal to x. Keep the original relative order inside each of the two groups.
The tests show a list as a Python list of its values: [1, 2, 3] stands for 1 -> 2 -> 3.
Example 1
Input:
partition_list(head, 3) # head = 1 -> 4 -> 3 -> 2 -> 5 -> 2
Output:
[1, 2, 2, 4, 3, 5]
Example 2
Input:
partition_list(head, 2) # head = 2 -> 1
Output:
[1, 2]
0 <= number of nodes <= 100000-1000 <= val, x <= 1000No results yet
Run your code to check it against the examples, or submit to run every test.