Trains the technique from
LeetCode 912Sort an ArrayThis 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 machine shop fills in a card for every finishing pass it runs. Each card carries one signed offset in microns: negative when the pass left the part under the nominal size, positive when it left the part over.
You are given offsets, the figures in the order the cards were filed. Return the same figures rearranged from lowest to highest. Every card keeps its own entry, so a figure filed three times has to appear three times in what you return.
Arrange the figures yourself: do not call a library sorting routine or ordering helper. Your routine must run in O(n log n) time and use as little extra room as you can manage.
Example 1
Both -4 cards and both 12 cards survive, so the answer holds five figures rising from -4 to 12.
Example 2
The seven figures are all different, so each one lands in its own place in the rising run.
Example 3
A single card is already in order on its own.
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 tool_offset_ordering(offsets: list[int]) -> list[int]:public int[] toolOffsetOrdering(int[] offsets)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.