Loading problem...
Given a collection of unique integers, your task is to produce every possible ordering (arrangement) of those integers. Each arrangement should contain all elements from the input exactly once, positioned in a different sequence. The result should encompass all valid orderings without repetition.
An arrangement of a set of elements is a specific ordering where each element appears exactly once. For a collection of n distinct elements, the total number of unique arrangements is n! (n factorial). For example, with 3 elements, there are 3! = 6 possible arrangements.
You may return the arrangements in any order — the order of the arrangements in your output does not matter, as long as all unique orderings are present and no duplicates exist.
nums = [1,2,3][[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]With three distinct numbers, there are 3! = 6 unique ways to arrange them. Each arrangement uses all three numbers exactly once in a different order.
nums = [0,1][[0,1],[1,0]]With two elements, there are only 2! = 2 possible arrangements: placing 0 first or placing 1 first.
nums = [1][[1]]A single element has exactly one arrangement — itself.
Constraints