Code Room
CodingMediumcod-g099
Subject Linked listsLevel Mid–Senior~20 minCommon in Distributed systems · Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.