Partition linked list by value
Given a singly linked list as a Python list of integers and a value x, partition the list so that all nodes with value strictly less than x come before all nodes with value greater than or equal to x. You must preserve the original relative order of nodes within each of the two partitions. Return the result as a Python list. The list has 0 to 200 nodes.
Implement
partition_list(values: list[int], x: int) → list[int]Examples
in
[[1,4,3,2,5,2],3]out[1,2,2,4,3,5]What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 20 min
solution.py
InputExpectedGot
[[1,4,3,2,5,2],3][1,2,2,4,3,5]not run yetsample