Question
Given an integer array values and an integer pivot, rearrange the array so that every element strictly less than pivot comes before every element greater than or equal to pivot, while preserving the original relative order inside each of the two groups (a stable partition). Return the rearranged array. A two-pass approach with a write pointer per group is fine. Example: values = [8, 3, 9, 2, 7], pivot = 7 gives [3, 2, 8, 9, 7].
stable_partition_below(values: list[int], pivot: int) → list[int][[8,3,9,2,7],7]out[3,2,8,9,7]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.