values that may contain repeated numbers. Return every distinct way to line these numbers up.
Two arrangements are the same if every position holds the same number. The arrangements may be listed in any order, but each must appear exactly once.values=[2, 2, 5] → [[2, 2, 5], [2, 5, 2], [5, 2, 2]]
The two 2s are indistinguishable, so there are only three distinct orders: 2 2 5, 2 5 2 and 5 2 2.
values=[0, -1] → [[-1, 0], [0, -1]]
Two different numbers give two orders.
values=[4, 4, 4] → [[4, 4, 4]]
All numbers are equal, so there is exactly one order.
values=[2, 2, 5]
[[2, 2, 5], [2, 5, 2], [5, 2, 2]]
Run checks the first 3 tests in your browser. Submit checks all 75 tests on the server, hidden ones included.