Trains the technique from
LeetCode 47Permutations IIThis 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 bench replays a batch of calibration steps, one after another. The batch is given as
steps, a list of signed millivolt values that may contain repeats.
A read-out is the sequence of numbers the bench prints when it plays every entry of the
batch exactly once, honouring repeats: a value appearing twice in steps is printed twice.
Two read-outs are the same when they print the same numbers in the same order, so
rearranging entries that hold equal values does not produce a new read-out.
Return every distinct read-out. The read-outs may be returned in any order.
Example 1
Each read-out prints both 2s and the single 1, and there are three ways the 1 can sit relative to the pair of 2s.
Example 2
The batch holds two copies of -1 and one 0, so the distinct read-outs are the three placements of the 0.
The values you return may be in any order.
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 distinct_step_orders(steps: list[int]) -> list[list[int]]:public List<List<Integer>> distinctStepOrders(int[] steps)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.