Trains the technique from
LeetCode 86Partition ListThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A survey tether carries a single file of sensor pods, each pod clipped to the one before it. The tether reaches you as pods, the list of calibration offsets in hanging order with the anchor end first, so pods[0] is the pod clipped to the anchor. Offsets may be negative. You are also given an integer threshold.
Re-clip the file so that every pod whose offset is below threshold ends up closer to the anchor than every pod whose offset is threshold or more. Inside each of those two stretches the pods keep the order they hung in when the tether arrived.
Work by unclipping whole pods and clipping them back on: an offset is never edited, and pods are not put in order by offset value. Return the offsets of the re-clipped tether in hanging order, anchor end first. The tether may arrive with no pods on it, in which case the answer is an empty list.
Example 1
Offsets 3, 1 and 2 are below 5, and they reach the anchor end still in that order. Offsets 9 and 7 are 5 or more and follow behind them, also in the order they arrived.
Example 2
The below-threshold pods 3, 3 and 1 come first in their arrival order, then 6, 8 and 9 in theirs. Two pods share the offset 3 and both are kept.
Example 3
The tether arrived with no pods clipped to it, so there is nothing to re-clip.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def retether_pods(pods: list[int], threshold: int) -> list[int]:public int[] retetherPods(int[] pods, int threshold)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.